13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

296 Co-operating Processes Chapter 91.1 Service calls<strong>Operating</strong> systems provide several process-creation service calls for the benefit of thecommand interpreter or any other process that might want to start a new process and waitfor it to finish. A typical set of calls includes the following.Load(file name). This call tells the operating system to take the load image storedin the named file and load it into a fresh process. The Load call returns someidentification for the new process, usually represented as a number.Join(process number). This call blocks the caller until the process with the givennumber has terminated.In addition, some operating systems provide simpler forms that have a similar power.Split. This call creates a new process that is just like the old process with respectto the contents of virtual space (although they don’t actually share virtual space)and with respect to what files are open. We say that the new process inherits theenvironment of the old one. The Split call returns a 0 to the child and the child’sprocess number to the parent, but otherwise they are identical.Execute(file name). This call tells the operating system to discard the virtualspace for the calling process and to replace it with a load image stored in thenamed file.The effect of Load can be achieved by Split followed by the child requesting Execute.1.2 Programming language syntaxThe service calls just listed also appear in some programming languages intended for usein distributed programming. For example, a process call in Modula can be seen as ashared-store Split call followed by the child jumping to the code for the desired process.Since it is so common to start a set of shared-store processes and then wait for all tofinish, a number of programming languages provide a cobegin construct that looks likethis:cobeginstatement executed by process 1statement executed by process 2...statement executed by process ncoendThis structure is equivalent to n Split operations, with each child executing its own statementand then terminating. The parent executes n Join operations to await the children’scompletions. However, one must be careful to distinguish between two different implementationsof the cobegin construct (or any other process-creation construct) in programminglanguages:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!