DOC PREVIEW
CMU CS 15213 - lecture

This preview shows page 1-2-3-4-26-27-28-53-54-55-56 out of 56 pages.

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

Unformatted text preview:

Carnegie Mellon Introduction to Computer Systems 15 213 fall 2009 14th Lecture Oct 14th Instructors Majd Sakr and Khaled Harras Carnegie Mellon ECF Exists at All Levels of a System Exceptions Hardware and operating system kernel Previous Lecture software Signals Kernel software Non local jumps Application code This Lecture Carnegie Mellon Today Multitasking shells Signals Long jumps More on signals Carnegie Mellon The World of Multitasking System runs many processes concurrently Process executing program State includes memory image register values program counter Regularly switches from one process to another Suspend process when it needs I O resource or timer event occurs Resume process when I O available or given scheduling priority Appears to user s as if all processes executing simultaneously Even though most systems can only execute one process at a time Except possibly with lower performance than if running alone Carnegie Mellon Programmer s Model of Multitasking Basic functions fork spawns new process Called once returns twice exit terminates own process Called once never returns Puts it into zombie status wait and waitpid wait for and reap terminated children execl and execve run new program in existing process Called once normally never returns Programming challenge Understanding the nonstandard semantics of the functions Avoiding improper use of system resources E g Fork bombs can disable a system Carnegie Mellon Unix Process Hierarchy 0 init 1 Daemon e g httpd Login shell Child Child Grandchild Child Grandchild Carnegie Mellon The ps command Unix ps aux w forest USER root root root root root root root root root root root root rpc rpcuser daemon root mmdf root root root root root root root root PID 1 2 3 4 5 6 9 12 397 484 533 538 563 578 696 713 721 732 738 739 752 753 744 774 786 TTY STAT S SW SWN SW SW SW SW SW S S S S S S S S S S S S L S L S L S S S output edited to fit slide COMMAND init 3 keventd ksoftirqd CPU0 kswapd bdflush kupdated mdrecoveryd scsi eh 0 sbin pump i eth0 usr local sbin afsd nosettime syslogd m 0 klogd 2 portmap rpc statd usr sbin atd usr local etc nanny init etc nanny conf usr local etc deliver b csmtpcmu usr local sbin named f usr local sbin sshd D usr local etc ntpd n usr local etc ntpd n usr local etc ntpd n usr local sbin zhm n zephyr 1 srv cm gpm t ps 2 m dev mouse crond Carnegie Mellon The ps Command cont USER root agn root agn agn agn agn agn agn agn agn agn agn agn agn agn agn agn agn agn agn agn PID 889 900 921 948 958 966 1184 1212 3346 1191 1204 1207 1208 1209 17814 2469 2483 2484 2485 3042 959 1020 TTY tty1 tty1 tty1 tty1 pts 0 pts 0 pts 0 pts 0 pts 0 8 pts 0 8 pts 0 8 pts 0 8 pts 0 8 pts 0 pts 0 pts 0 pts 0 pts 0 pts 0 tty1 tty1 STAT COMMAND S bin login agn S xinit 0 SL etc X11 X auth usr1 agn Xauthority 0 S bin sh afs cs cmu edu user agn xinitrc S xterm geometry 80x45 1 1 C j ls n S tcsh S usr local bin wish8 0 f usr S usr local bin wish8 0 f S aspell a S S bin sh usr local libexec moz S usr local libexec mozilla S usr local libexec moz S usr local libexec S usr local libexec S usr local libexec S usr local lib Acrobat S java vm S java vm S java vm S java vm S bin sh usr local libexec kde bin sta S kwrapper ksmserver Carnegie Mellon Unix Startup Step 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 binary e g boot vmlinux 4 Boot block program passes control to kernel 5 Kernel handcrafts the data structures for process 0 0 Process 0 handcrafted kernel process Process 0 forks child process 1 init 1 Child process 1 execs sbin init Carnegie Mellon Some PC Start up Details Boot Disk CD Floppy CPU 0xffffffff 0xffff0000 0x00000000 BIOS ROM Carnegie Mellon Some PC Start up Details Boot Disk CD Floppy CPU Power on Reset 0xffffffff 0xffff0000 0x00000000 BIOS ROM Carnegie Mellon Some PC Start up Details Boot Disk CD Floppy Start Execution at 0xfffffff0 CPU 0xffffffff 0xffff0000 0x00000000 BIOS ROM Carnegie Mellon Some PC Start up Details Boot Disk CD Floppy CPU 0xffffffff 0xffff0000 Copy Master Boot Record MBR into memory 0x00007c00 0x00000000 BIOS ROM Carnegie Mellon Some PC Start up Details Boot Disk CD Floppy CPU 0xffffffff 0xffff0000 BIOS verifies MBR and jumps to 0x00007c00 0x00007c00 0x00000000 BIOS ROM Carnegie Mellon Some PC Start up Details Boot Disk CD Floppy CPU 0xffffffff 0xffff0000 LILO or GRUB is loaded from first sector of active partition 0x00007c00 0x00000000 BIOS ROM Carnegie Mellon Some PC Start up Details Boot Disk CD Floppy CPU 0xffffffff 0xffff0000 CPU executes LILO 0x00007c00 0x00000000 BIOS ROM Carnegie Mellon Some PC Start up Details Boot Disk CD Floppy CPU 0xffffffff 0xffff0000 The Linux kernel is loaded and begins initialization 0x00007c00 0x00000000 BIOS ROM Carnegie Mellon Unix Startup Step 2 0 etc inittab Daemons e g ftpd httpd init 1 getty init forks and execs daemons per etc inittab and forks and execs a getty program for the console Carnegie Mellon Unix Startup Step 3 0 init 1 login The getty process execs a login program Carnegie Mellon Unix Startup Step 4 0 init 1 tcsh login reads login ID and passwd if OK it execs a shell if not OK it execs another getty In case of login on the console xinit may be used instead of a shell to start the window manger Carnegie Mellon Shell Programs A shell is an application program that runs programs on behalf of the user sh csh bash Original Unix shell Stephen Bourne AT T Bell Labs 1977 BSD Unix C shell tcsh csh enhanced at CMU and elsewhere Bourne Again Shell int main char cmdline MAXLINE while 1 read printf Fgets cmdline MAXLINE stdin if feof stdin exit 0 evaluate eval cmdline Execution is a sequence of read evaluate steps Carnegie Mellon Simple Shell eval Function void eval char cmdline char argv MAXARGS argv for execve int bg should the job run in bg or fg pid t pid process id bg parseline cmdline argv if builtin command argv if pid Fork 0 child runs user job if execve argv 0 argv environ 0 printf s Command not found n argv 0 exit 0 if bg parent waits for fg job to terminate int status if waitpid pid status 0 0 unix error waitfg waitpid error else otherwise don t wait for bg job printf d s pid cmdline Carnegie Mellon What Is a Background Job Users generally run one command at a time Type command read output type another command Some programs run for a long time …


View Full Document

CMU CS 15213 - lecture

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

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 lecture
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 lecture 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 lecture 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?