CSC209H5 Chapter Notes - Chapter 7: Init, Process Identifier, Exit Status

40 views6 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) The programmer cannot control whether the parent or child process executes first after they are referred from fork. The order of the output may be different each time the program is runned. /* a program that creates several processes */ // original process prints a message that includes its pid and parent pid printf( "[%d] original process (my parent is %d)\n" , getpid(), getppid()); // each child process executes 5 interactions of a loop else if (result == 0 ) { //child process. For (j = 0 ; j < 5 ; j++) { //prints a message and sleep for a specified amount of time printf( "[%d] child %d %d\n" , getpid(), i, j); // slow processes down enough to see how the process is run concurrently. // control is passed to the operating system to decide which process will run next.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents