Processes and Threads

The material on this Page is meant to be a brief review of some operating system terminology. Although the details are presented in the context of the Unix operating system, it is really the underlying functionality captured by these terms that is important for this course. This functionality is more or less present in most familiar operating systems.


A Unix Process consists of:

The process is the basic scheduling unit for the operating system.

A Unix Thread (of execution) can be thought of as a member of collection of instances of a single program running in multiple places at the same time:


The differences between Processes and Threads are reflected in the system calls:


Communications

Sockets :

Socket protocols provide for a bidirectional flow of data between processes that may or may not live on the same host. Once sockets have be created and the connections between processes have been established, using sockets have the same characteristics as reading an writing to files. The following provides a bit more detail:

On the server side:

  1. Create a socket with socket().
  2. bind() the socket to an address (IP address and port number).
  3. listen() for a connection.
  4. accept() a connection.
  5. Send and receive data For example, use read() and write() .

On the client side:

  1. Create a socket with socket().
  2. Connect the socket to the address of the server using connect().
  3. Send and receive data.

 

Shared Memory:

As the phrase suggests, shared memory a common region of memory (address space) where the sharing processes or threads may all read or write. This can be a particularly efficient means of Inter Process Communications since it does not require any operating system overhead. On the other hand it does require some form of synchronization between the processes or threads to guaranty the integrity of the data in the shared memory region.