Generic Process Operations

Contents

Introduction
Concurrent processes
Process Operations
Process creation
Standard C API

Introduction

Processes are the things that actually do the work.

Program

A program is a sequence of instructions. A program may be C source code. After compilation there is a program which is executable code. Neither of these actually do anything. Programs are stored on disk as static entities.

Process

A process is a dynamic invocation of a program along with the resources required to run. These include user and system stacks, memory, file handles, etc. Each process generally runs in a separate address space.

Concurrent processes

A process is usually sequential and consists of a sequence of actions that take place one at a time. When a set of processes are run on a single CPU, using timeslicing to multitask them, this is referred to as concurrent sequential processing or pseudo-parallel processing. If there is more than one CPU available, then processes may be run in parallel.

Process Operations

The set of operations on processes includes The O/S will supply mechanisms for at least some of these.

Process creation

There must be a mechanism for creating processes by the O/S. A new process will be created using an existing one. There are several possible organisations of this.

Synchronous

If a process is created from another as a synchronous process then the new must complete execution before the old one can resume.

Asynchronous

If the new process is created asynchronously, then the two processes may be run in pseudo-parallel.

Parent

When a new process is created, it may use the old one as ``parent''. This is done in MSDOS and Unix. Alternatively, there may be no relation between the original and the new process, as in Windows NT.

Granularity

Processes vary in the amount of complexity required to set them up and the amount of sharing with the parent.

Standard C API

The standard C library has a call
#include 
int system(char *command)
This creates a new synchronous process. It does so by passing the command to the command processor (eg bash) which executes in the current command processor environment. When the process completes the system call finishes and the calling process can continue.

Example:

Read lines from standard input and execute them as commands.
#include <stdio.h>

int main(void)
{  char command[1024];

   printf("Enter commands, one per line:\n");
   while (gets(command) != NULL)
      system(command);
   exit(0);
}


The called process may in turn make a call to ``system''. This allows a stack of processes to be built, each of which is suspended when a new process is placed on the stack, and can resume when it becomes the top-of-stack process again. This mechanism is available in both MSDOS and Unix. Program Development using Unix Home
Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Copyright © Jan Newmarch
Last modified: Wed Sep 10 09:54:31 EST 1997