





































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






































1
2
needed to run it
4
phase) of a process.
5
(Figure 3.2, p. 101) Docsity.com
7
8
process context
In what address space are PCB’s stored?
What is this?
Also: Process priority
10
Linux process switch code (pp. 383-394, Linux scheduler, "The Linux Kernel Primer"; Handout) Docsity.com
11
right word?
right word?
of data structure to organize them
13
14
Note the names
17
int fork(); // returns child pid in parent
19
(One pattern of usage: exec is optional and waiting for child to die is optional)
20
#include <stdio.h> /* Example of creating a new process on UNIX (BSD; OS X) */ #include <sys/types.h> #include <unistd.h> #include <sys/wait.h>
int a = 1;
int main() { int status; int pid = fork(); if (-1 == pid) { printf("Eror calling fork\n"); } else if (0 == pid) { /* in child process / printf("Press enter to continue in child...\n"); fflush(stdout); getchar(); a = 10; // return from child, and terminate } else { / in parent process */ printf("Value of 'a' before waiting for child= %d\n", a); wait(&status); // status will have pid of child printf("Value of 'a' after waiting for child= %d\n", a); fflush(stdout); } }
OUTPUT: Value of 'a' before waiting for child= 1 Press enter to continue in child... Value of 'a' after waiting for child= 1
Docsity.com