CMU CS 15213 - Lecture (18 pages)

Previewing pages 1, 2, 3, 4, 5, 6 of 18 page document View the full content.
View Full Document

Lecture



Previewing pages 1, 2, 3, 4, 5, 6 of actual document.

View the full content.
View Full Document
View Full Document

Lecture

377 views

Lecture Notes


Pages:
18
School:
Carnegie Mellon University
Course:
Cs 15213 - Introduction to Computer Systems
Introduction to Computer Systems Documents

Unformatted text preview:

15 213 The course that gives CMU its Zip L5 Writing Your Own Unix Shell October 16 2006 Topics L5 Shell Lab Processes Signals Reminders Shell Lab Due Oct 25 2006 wed Section A Donnie Kim recitation6 ppt some slides courtesy of Kun Gao S05 and Minglong Shao F04 L5 Tiny Shell tsh Things to learn from this lab Process Control Ch 8 Process ID PID and Process Group ID Parent and Child process Loading and running program fork execve waitpid Signals Ch 8 Sending and receiving signals Pending signal Blocking unblocking signal avoiding race hazards I O redirection Ch 11 dup2 2 15 213 F 06 Related Background Review Preview 3 15 213 F 06 Process Control Process ID Process Group ID and Parent Process ID Each process has its own unique process ID pid t getpid void returns my pid Every process belong to exactly one process group pid t getpgrp void returns my prg id Process creates process parent child pid t getppid void returns my parent s pid dhjkim bluefish tshlab handout ps jf UID PID PPID PGID SID C STIME dhjkim 5469 5465 5469 5469 0 00 17 dhjkim 6284 5469 6284 5469 99 00 54 test dhjkim 10139 5469 10139 5469 0 03 53 jf 4 TTY pts 7 pts 7 TIME CMD 00 00 00 tcsh 02 58 42 pts 7 00 00 00 ps 15 213 F 06 fork Creating New Processes int fork void 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 Fork is interesting and often confusing because it is called once but returns twice Any Scheduling order is Possible 5 First parent then child or first child then parent can be executed depending on how OS scheduler decides 15 213 F 06 exec Loading and Running Programs int execve char fname char argv char envp New Program fname overwrites its state and takes over the process PID main if fork 0 execve usr bin ls NULL NULL wait NULL exit 6 15 213 F 06 waitpid Waiting for a Specific Process waitpid pid status



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

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?