DOC PREVIEW
CMU CS 15213 - 16-virtual-memory

This preview shows page 1-2-3-25-26-27-28-50-51-52 out of 52 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 52 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Carnegie Mellon Introduction to Computer Systems 15 213 18 243 spring 2009 16th Lecture Mar 17th Instructors Gregory Kesden and Markus P schel Carnegie Mellon Signals Kernel Process Process Process using kill 32 types of signals Sent by updating bit in pending vector You can write your own signal handlers ID 2 9 11 14 17 Name SIGINT SIGKILL SIGSEGV SIGALRM SIGCHLD Default Action Terminate Terminate Terminate Dump Terminate Ignore Corresponding Event Interrupt e g ctl c from keyboard Kill program cannot override or ignore Segmentation violation Timer signal Child stopped or terminated Carnegie Mellon Signal Handlers as Concurrent Flows Process A Signal delivered Icurr Process B user code main kernel code context switch user code main kernel code Signal received user code handler kernel code Inext user code main context switch Carnegie Mellon Today More on signals Long jumps Virtual memory VM Overview and motivation VM as tool for caching VM as tool for memory management VM as tool for memory protection Address translation Carnegie Mellon Sending Signals from the Keyboard Typing ctrl c ctrl z sends a SIGINT SIGTSTP to every job in the foreground process group SIGINT default action is to terminate each process SIGTSTP default action is to stop suspend each process pid 10 pgid 10 pid 20 pgid 20 Background job 1 Foreground job Child Child pid 21 pgid 20 pid 22 pgid 20 Foreground process group 20 Shell pid 32 pgid 32 Background process group 32 Background job 2 pid 40 pgid 40 Background process group 40 Carnegie Mellon Example of ctrl c and ctrl z bluefish forks 17 Child pid 28108 pgrp 28107 Parent pid 28107 pgrp 28107 types ctrl z Suspended bluefish ps w PID TTY STAT TIME COMMAND 27699 pts 8 Ss 0 00 tcsh 28107 pts 8 T 0 01 forks 17 28108 pts 8 T 0 01 forks 17 28109 pts 8 R 0 00 ps w bluefish fg forks 17 types ctrl c bluefish ps w PID TTY STAT TIME COMMAND 27699 pts 8 Ss 0 00 tcsh 28110 pts 8 R 0 00 ps w STAT process state Legend First letter S sleeping T stopped R running Second letter s session leader foreground proc group See man ps for more details Carnegie Mellon Signal Handler Funkiness int ccount 0 void child handler int sig int child status pid t pid wait child status ccount printf Received signal d from process d n sig pid void fork14 pid t pid N int i child status ccount N signal SIGCHLD child handler for i 0 i N i if pid i fork 0 sleep 1 deschedule child exit 0 Child Exit while ccount 0 pause Suspend until signal occurs Pending signals are not queued For each signal type just have single bit indicating whether or not signal is pending Even if multiple processes have sent this signal Carnegie Mellon Living With Nonqueuing Signals Must check for all terminated jobs Typically loop with wait void child handler2 int sig int child status pid t pid while pid waitpid 1 child status WNOHANG 0 ccount printf Received signal d from process d n sig pid void fork15 signal SIGCHLD child handler2 Carnegie Mellon Signal Handler Funkiness Cont Signal arrival during long system calls say a read Signal handler interrupts read call Linux upon return from signal handler the read call is restarted automatically Some other flavors of Unix can cause the read call to fail with an EINTER error number errno in this case the application program can restart the slow system call Subtle differences like these complicate the writing of portable code that uses signals Carnegie Mellon A Program That Reacts to Externally Generated Events Ctrl c include stdlib h include stdio h include signal h void handler int sig printf You think hitting ctrl c will stop the bomb n sleep 2 printf Well fflush stdout sleep 1 printf OK n exit 0 main signal SIGINT handler installs ctrl c handler while 1 Carnegie Mellon A Program That Reacts to Internally Generated Events include stdio h include signal h int beeps 0 SIGALRM handler void handler int sig printf BEEP n fflush stdout if beeps 5 alarm 1 else printf BOOM n exit 0 main signal SIGALRM handler alarm 1 send SIGALRM to process in 1 second while 1 handler returns here linux a out What happens Carnegie Mellon A Program That Reacts to Internally Generated Events include stdio h include signal h int beeps 0 SIGALRM handler void handler int sig printf BEEP n fflush stdout if beeps 5 alarm 1 else printf BOOM n exit 0 main signal SIGALRM handler alarm 1 send SIGALRM to process in 1 second while 1 handler returns here linux a out BEEP BEEP BEEP BEEP BEEP BOOM bass Carnegie Mellon Summary Signals provide process level exception handling Can generate from user programs Can define effect by declaring signal handler Some caveats Very high overhead 10 000 clock cycles Only use for exceptional conditions Don t have queues Just one bit for each pending signal type Carnegie Mellon Today More on signals Long jumps Virtual memory VM Overview and motivation VM as tool for caching VM as tool for memory management VM as tool for memory protection Address translation Carnegie Mellon Nonlocal Jumps setjmp longjmp Powerful but dangerous user level mechanism for transferring control to an arbitrary location Controlled to way to break the procedure call return discipline Useful for error recovery and signal handling int setjmp jmp buf buf Must be called before longjmp Identifies a return site for a subsequent longjmp Called once returns one or more times Implementation Remember where you are by storing the current register context stack pointer and PC value in jmp buf Return 0 Carnegie Mellon setjmp longjmp cont void longjmp jmp buf buf int i Meaning return from the setjmp remembered by jump buffer buf again this time returning i instead of 0 Called after setjmp Called once but never returns longjmp Implementation Restore register context stack pointer base pointer PC value from jump buffer buf Set eax the return value to i Jump to the location indicated by the PC stored in jump buf buf Carnegie Mellon setjmp longjmp Example include setjmp h jmp buf buf main if setjmp buf 0 printf back in main due to an error n else printf first time through n p1 p1 calls p2 which calls p3 p3 error checking code if error longjmp buf 1 Carnegie Mellon Limitations of Nonlocal Jumps Works within stack discipline Can only long jump to environment of function that has been called but not yet completed jmp buf env P1 if setjmp buf long jump to here else P2 P2 P2 P3 P3 longjmp buf 1 Before longjmp After longjmp buf P1 P2 P2 P2 P3 P1 Carnegie Mellon Limitations of Long Jumps cont Works within stack discipline Can only long


View Full Document

CMU CS 15213 - 16-virtual-memory

Documents in this Course
lecture

lecture

14 pages

lecture

lecture

46 pages

Caches

Caches

9 pages

lecture

lecture

39 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

56 pages

lecture

lecture

11 pages

lecture

lecture

9 pages

Lecture

Lecture

36 pages

Lecture

Lecture

37 pages

Exam

Exam

16 pages

Lecture

Lecture

10 pages

Lecture

Lecture

43 pages

Lecture

Lecture

8 pages

Lecture

Lecture

8 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

37 pages

Lecture

Lecture

6 pages

Lecture

Lecture

40 pages

coding

coding

2 pages

Exam

Exam

17 pages

Exam

Exam

14 pages

Lecture

Lecture

29 pages

Lecture

Lecture

34 pages

Exam

Exam

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

lecture

lecture

46 pages

Lecture

Lecture

33 pages

Lecture

Lecture

57 pages

Lecture

Lecture

32 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

11 pages

Lecture

Lecture

6 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

18 pages

Exam

Exam

10 pages

Lecture

Lecture

45 pages

Lecture

Lecture

37 pages

Exam

Exam

24 pages

class09

class09

21 pages

class22

class22

37 pages

class20

class20

30 pages

class27

class27

33 pages

class25

class25

21 pages

class04

class04

31 pages

Lecture

Lecture

59 pages

class01a

class01a

14 pages

class12

class12

45 pages

class29

class29

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

6 pages

class03

class03

34 pages

lecture

lecture

42 pages

Lecture

Lecture

40 pages

Lecture

Lecture

47 pages

Exam

Exam

19 pages

R06-B

R06-B

25 pages

class17

class17

37 pages

class25

class25

31 pages

Lecture

Lecture

15 pages

final-f06

final-f06

17 pages

Lecture

Lecture

9 pages

lecture

lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

22 pages

class11

class11

45 pages

lecture

lecture

50 pages

Linking

Linking

37 pages

Lecture

Lecture

64 pages

Integers

Integers

40 pages

Exam

Exam

11 pages

Lecture

Lecture

37 pages

Lecture

Lecture

44 pages

Lecture

Lecture

37 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

45 pages

Final

Final

25 pages

lecture

lecture

9 pages

Lecture

Lecture

30 pages

Lecture

Lecture

16 pages

Final

Final

17 pages

Lecture

Lecture

8 pages

Exam

Exam

11 pages

Lecture

Lecture

47 pages

Lecture

Lecture

9 pages

lecture

lecture

39 pages

Exam

Exam

11 pages

lecture

lecture

41 pages

lecture

lecture

37 pages

Lecture

Lecture

59 pages

Lecture

Lecture

45 pages

Exam 1

Exam 1

18 pages

Lecture

Lecture

41 pages

Lecture

Lecture

32 pages

Lecture

Lecture

30 pages

Lecture

Lecture

9 pages

Lecture

Lecture

9 pages

Lecture

Lecture

15 pages

Lecture

Lecture

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

4 pages

Lecture

Lecture

46 pages

Lecture

Lecture

8 pages

Lecture

Lecture

65 pages

Lecture

Lecture

38 pages

Lecture

Lecture

35 pages

Lecture

Lecture

8 pages

Lecture

Lecture

34 pages

Lecture

Lecture

8 pages

Exam

Exam

13 pages

Lecture

Lecture

43 pages

Lecture

Lecture

9 pages

Lecture

Lecture

12 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

43 pages

Lecture

Lecture

7 pages

Lecture

Lecture

45 pages

Lecture

Lecture

24 pages

Lecture

Lecture

47 pages

Lecture

Lecture

12 pages

Lecture

Lecture

20 pages

Lecture

Lecture

9 pages

Exam

Exam

11 pages

Lecture

Lecture

52 pages

Lecture

Lecture

20 pages

Exam

Exam

11 pages

Lecture

Lecture

35 pages

Lecture

Lecture

47 pages

Lecture

Lecture

18 pages

Lecture

Lecture

30 pages

Lecture

Lecture

59 pages

Lecture

Lecture

37 pages

Lecture

Lecture

22 pages

Lecture

Lecture

35 pages

Exam

Exam

23 pages

Lecture

Lecture

9 pages

Lecture

Lecture

22 pages

class12

class12

32 pages

Lecture

Lecture

8 pages

Lecture

Lecture

39 pages

Lecture

Lecture

44 pages

Lecture

Lecture

38 pages

Lecture

Lecture

69 pages

Lecture

Lecture

41 pages

Lecture

Lecture

12 pages

Lecture

Lecture

52 pages

Lecture

Lecture

59 pages

Lecture

Lecture

39 pages

Lecture

Lecture

83 pages

Lecture

Lecture

59 pages

class01b

class01b

17 pages

Exam

Exam

21 pages

class07

class07

47 pages

Lecture

Lecture

11 pages

Odyssey

Odyssey

18 pages

multicore

multicore

66 pages

Lecture

Lecture

6 pages

lecture

lecture

41 pages

lecture

lecture

55 pages

lecture

lecture

52 pages

lecture

lecture

33 pages

lecture

lecture

46 pages

lecture

lecture

55 pages

lecture

lecture

17 pages

lecture

lecture

49 pages

Exam

Exam

17 pages

lecture

lecture

56 pages

Exam 2

Exam 2

16 pages

Exam 2

Exam 2

16 pages

Notes

Notes

37 pages

Lecture

Lecture

40 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Exam

Exam

13 pages

Lecture

Lecture

32 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

29 pages

Lecture

Lecture

59 pages

Lecture

Lecture

41 pages

Lecture

Lecture

50 pages

Exam

Exam

17 pages

Lecture

Lecture

29 pages

Lecture

Lecture

44 pages

Lecture

Lecture

41 pages

Lecture

Lecture

52 pages

Lecture

Lecture

40 pages

Lecture

Lecture

33 pages

lecture

lecture

10 pages

Lecture

Lecture

27 pages

Lecture

Lecture

29 pages

Lecture

Lecture

39 pages

Lecture

Lecture

9 pages

Lecture

Lecture

29 pages

Lecture

Lecture

8 pages

Lecture

Lecture

43 pages

Lecture

Lecture

43 pages

Lecture

Lecture

75 pages

Lecture

Lecture

55 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lecture

Lecture

35 pages

lecture

lecture

36 pages

Exam

Exam

33 pages

lecture

lecture

56 pages

lecture

lecture

64 pages

lecture

lecture

8 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

36 pages

lecture

lecture

56 pages

lecture

lecture

75 pages

lecture

lecture

36 pages

Lecture

Lecture

50 pages

Lecture

Lecture

45 pages

Lecture

Lecture

13 pages

Exam

Exam

23 pages

Lecture

Lecture

10 pages

Lecture

Lecture

48 pages

Lecture

Lecture

83 pages

lecture

lecture

57 pages

Lecture

Lecture

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

33 pages

lecture

lecture

54 pages

Lecture

Lecture

30 pages

Exam

Exam

13 pages

Lecture

Lecture

36 pages

Lecture

Lecture

40 pages

Exam

Exam

17 pages

Lecture

Lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

44 pages

Lecture

Lecture

34 pages

Lecture

Lecture

24 pages

Lecture

Lecture

29 pages

class12

class12

43 pages

lecture

lecture

43 pages

class22

class22

22 pages

R06-B

R06-B

25 pages

class01b

class01b

19 pages

lecture

lecture

29 pages

lab1

lab1

8 pages

Caches

Caches

36 pages

lecture

lecture

55 pages

Lecture,

Lecture,

37 pages

Integers

Integers

40 pages

Linking

Linking

38 pages

lecture

lecture

45 pages

Lecture

Lecture

61 pages

Linking

Linking

33 pages

lecture

lecture

40 pages

lecture

lecture

40 pages

Lecture

Lecture

32 pages

lecture

lecture

48 pages

lecture

lecture

44 pages

Exam

Exam

11 pages

Lecture

Lecture

31 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

40 pages

Exam

Exam

12 pages

Lecture

Lecture

42 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

Lecture

Lecture

13 pages

Lecture

Lecture

35 pages

Lecture

Lecture

20 pages

Final

Final

19 pages

Lecture

Lecture

33 pages

Lecture

Lecture

50 pages

Lecture

Lecture

33 pages

Lecture

Lecture

27 pages

Lecture

Lecture

6 pages

Exam

Exam

15 pages

Lecture

Lecture

24 pages

Lecture

Lecture

23 pages

Lecture

Lecture

43 pages

Lecture

Lecture

32 pages

Lecture

Lecture

52 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

15 pages

lecture

lecture

21 pages

Lecture

Lecture

58 pages

Lecture

Lecture

49 pages

Lecture

Lecture

36 pages

Lecture

Lecture

11 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

33 pages

Exam

Exam

15 pages

Lecture

Lecture

35 pages

Lecture

Lecture

10 pages

Lecture

Lecture

25 pages

Lecture

Lecture

31 pages

Lecture

Lecture

24 pages

Lecture

Lecture

34 pages

Lecture

Lecture

50 pages

lecture

lecture

35 pages

Lecture

Lecture

11 pages

Lecture

Lecture

39 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

exam1-f05

exam1-f05

11 pages

Lecture

Lecture

4 pages

Lecture

Lecture

17 pages

Exam

Exam

17 pages

malloc()

malloc()

12 pages

Lecture

Lecture

57 pages

Lecture

Lecture

30 pages

Lecture

Lecture

30 pages

Lecture

Lecture

47 pages

Lecture

Lecture

33 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lectures

Lectures

33 pages

Lecture

Lecture

36 pages

lecture

lecture

33 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Load more
Download 16-virtual-memory
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view 16-virtual-memory and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view 16-virtual-memory and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?