DOC PREVIEW
CMU CS 15213 - Program Translation and Execution II

This preview shows page 1-2-23-24 out of 24 pages.

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

Unformatted text preview:

15 213 Introduction to Computer Systems Program Translation and Execution II Processes Oct 1 1998 Topics User level view of processes Implementation of processes setjmp longjmp class12 ppt Processe A process is an instance of a running s program runs concurrently with other processes multitasking managed by a shared piece of OS code called the kernel kernel is not a separate process but rather runs as part of some user process each process has its own data space and process id pid data for each protected protected from other processes Process A Process B user code kernel code Time user code kernel code Just a stream of instructions user code class12 ppt 2 CS 213 F 98 int fork void Fork creates a new process child process that is identical to the calling process parent process returns 0 to the child process returns child s pid to the parent process if fork 0 printf hello from child n else printf hello from parent n class12 ppt 3 CS 213 F 98 Exit void exit int status exits a process atexit function registers functions to be executed on exit void cleanup void printf cleaning up n main atexit cleanup if fork 0 printf hello from child n else printf hello from parent n exit class12 ppt 4 CS 213 F 98 Wait int wait int child status waits for a child to terminate and returns status and pid main int child status if fork 0 printf hello from child n else printf hello from parent n wait child status printf child has terminated n exit class12 ppt 5 CS 213 F 98 Exec int execl char path char arg0 char arg1 loads and runs executable at path with args arg0 arg1 returns 1 if error otherwise doesn t return main if fork 0 execl usr bin cp cp foo bar 0 wait NULL printf copy completed n exit class12 ppt 6 CS 213 F 98 Example Concurrent network server void main master sockfd sl passivesock port create master socket while 1 slave sockfd sl acceptsock master sockfd await request switch fork case 0 child closes its master and manipulates slave close master sockfd code to read and write to from slave socket goes here exit 0 default parent closes its copy of slave and repeats close slave sockfd case 1 error fprintf fork error n exit 0 class12 ppt 7 CS 213 F 98 Process hierarchy 0 init 1 Daemon e g snmp shell child child grandchild class12 ppt child grandchild 8 CS 213 F 98 Unix startup 1 1 Pushing reset button loads the pc with the address of a small bootstrap program 2 Bootstrap program loads the boot block disk block 0 3 Boot block program loads kernel e g vmunix 4 Boot block program passes control to kernel 5 Kernel handcrafts the data structures for process 0 0 init 1 class12 ppt process 0 handcrafted kernel process process 1 user mode process fork and exec sbin init 9 CS 213 F 98 Unix startup 2 0 etc inittab Daemons e g snmp class12 ppt init 1 getty 10 init forks new processes as per the etc inittab file forks a getty get tty or get terminal for the console CS 213 F 98 Unix startup 3 0 init 1 login class12 ppt 11 getty execs a login program CS 213 F 98 Unix startup 4 0 init 1 login gets user s login and passw if OK it execs a shell if not OK it execs another getty tcsh class12 ppt 12 CS 213 F 98 Loading and running programs from a shell read command line until EOF while read stdin buffer numchars parse command line if command line contains amper 1 else amper 0 for commands not in the shell command language if fork 0 execl cmd cmd 0 if amper 0 retpid wait status class12 ppt 13 CS 213 F 98 Process memory image Reserved for kernel Alpha 0xffff ffff ffff ffff 0xffff fc00 0000 0000 0xffff fbff ffff ffff 0x0000 0400 0000 0000 0x0000 03ff ffff ffff 0x0000 03ff 8000 0000 0x0000 03ff 7fff ffff Not accessible Reserved for shared libraries and dynamic loader Available for heap Heap via malloc or sbrk Grows up Bss segment gp 0x0000 0001 2000 0000 0x0000 0000 1fff ffff sp 0x0000 0000 0001 0000 0x0000 0000 0000 ffff 0x0000 0000 0000 0000 class12 ppt Data segment Text segment Stack Grows down to zero Available for stack Not accessible by convention 64KB 14 CS 213 F 98 Kernel block diagram User programs libraries User level Kernel level system call interface file system process control buffer cache char block device drivers Kernel level Hw level class12 ppt hardware control interrupt and exception handlers hardware processor and devices 15 CS 213 F 98 User and kernel modes User mode Process can execute its own instructions and access its own data Process cannot execute kernel instructions or privileged instructions e g halt access kernel data or data from other processes Kernel mode Process can execute kernel instructions and privileged instructions access kernel and user addresses Processes transition from user to kernel mode via interrupts and exceptions system calls traps class12 ppt 16 CS 213 F 98 System call interface System calls traps are expected program events e g fork exec wait getpid User code call user level library function executes special syscall instruction e g syscall id switch from user mode to kernel mode transfer control to kernel system call interface System call interface find entry in syscall table corresponding to id determine number of parameters copy parameters from user member to kernel memory save current process context in case of abortive return invoke appropriate function in kernel class12 ppt 17 CS 213 F 98 Hardware control Interrupts and exceptions are unexpected hardware events Interrupts events external to the processor I O device asking for attention timer interrupt typically indicated by setting an external pin Exceptions events internal to processor as a result of executing an instruction divide by zero Same mechanism handles both Interrupt or exception triggers transfer of control from user code to interrupt handlers in the hardware control part of the kernel kernel services interrupt or exception If a timer interrupt kernel might decide to give control to a new process context switch class12 ppt 18 CS 213 F 98 Process control Context of a process The context of a process is the state that is necessary to restart the process if its interrupted Union of user level context register context system level context User level context text data and bss segments and user stack Register context PC general purpose integer and floating point regs IEEE rounding mode kernel stack pointer process table address System level context various OS tables process and memory tables kernel stack class12 ppt 19 CS 213 F 98 Process control Context switch The kernel can decide to pass control to another


View Full Document

CMU CS 15213 - Program Translation and Execution II

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 Program Translation and Execution II
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 Program Translation and Execution II 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 Program Translation and Execution II 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?