Concurrent Processes n n n Processes can concurrently
- Slides: 11
Concurrent Processes n n n Processes can concurrently run same program. Processes can start other processes. UNIX provides concurrency functions
Creating New Processes n system -- makes a shell n Exec -- replace this process with a new one n Fork -- start a concurrent process
Example “System” int main() { char buffer[80]; strcpy(buffer, “wc *. *”); system(buffer); }
The exec( ) Family char *path, *file; char *arg 0, *arg 1, . . . , *argn; char *argv[ ]; int ret; ret = execl (path, arg 0, arg 1, . . . , argn, (char *)0); ret = execv (path, argv); ret = execlp (file, arg 0, arg 1, . . . , argn, (char *) 0); ret = execvp (file, argv);
The fork( ) Facility n n n Basic process creation primitive. Duplicates the calling process. New process child process Initiating process is parent. Returns child’s process-id
Inherited Data and File Descriptors n n n Forked child has instances of current values of the variables and open file descriptors. Variables; “pass” by copy Read/write pointers for a file; reference
wait( ) n n n int wait (int * status) Suspends execution of process while child runs Parent resumes upon child termination When the first child process terminates Normally returns process-id of exiting child. On error, wait( ) returns a -1, usually meaning no child exists on which to wait.
Zombies and Premature Exits n Zombie processes are ones that somehow lose connection with the parent. How? Zombie occupies a slot in process table, but uses no system resources. Zombie cleared when parent “claims” child Wait removes chance of zombie? ? ? n Parent exits B 4 children premature exit n n n
Process and Group Id’s n n pid = getpid( ); pid = getppid( ); newpg = setpgrp( ); pgid = getpgrp( ); its own process id parent process id change group access group
UNIX Signals SIGHUP SIGINT SIGQUIT SIGILL SIGTRAP SIGFPE SIGKILL SIGSYS SIGPIPE SIGALRM SIGTERM SIGUSR 1 SIGUSR 2 - The hangup signal, sent upon user logout - Interrupt signal, sent on user break signal - Quit signal, sent when user hits quit key - Illegal Instruction signal - Trace trap signal used by debuggers - Floating-Point exception signal - Sent process n to terminate process m - Bad argument to a system call signal - Write on a pipe with no one to read it - Alarm clock signal used for software timers - Software signal to terminate process - user signal
pause( ) int pause( ) suspends the calling process, without wasting resources, until some kind of signal is received.
- Tier standard topology
- Concurrent in os
- Coplanar force system
- Point of concurrency of medians
- Concurrent process model in embedded systems
- Concurrent versions system
- Prospective validation
- Lesson 5-3 concurrent lines medians and altitudes
- 5-1 bisectors of triangles
- Practice 5-3 concurrent lines medians and altitudes
- Concurrent events examples
- Concurrent and distributed systems