CS GRIND

CSC Notes Chapter 3 Processes

Chapter Objectives

  • To introduce the notion of a process - a program in execution that forms the basis of a lll computation.
  • To describe the various feature of processes, including scheduling, creation and termination, and communication.
  • To describe communication in client-server systems.

Process Concept

A process is a program in execution.

The process

A process (may) includes:

A program by itself is not a process; a program is a passive entity, such as a file containing a list of instructions stored on disk(often called an executable file), whereas a process is an active entity, with a program counter specifying the next instruction to execute and a set of associated resources. A program becomes a process when an executable file is loaded into memory.

Process State

Each process may be in one of the following states(maybe not exactly with the same name):

Process Control Block

Each process is represented by a process control block(PCB). A PCB contains:

Threads

Process Scheduling

Scheduling Queues

Dispatch

A new process is initially put in the ready queue. It waits there until it is selected for execution, or is dispatched.

Once the process is allocated the CPU and is executing, one of several events could occur:

Schedulers

Context Switch

Switching the CPU to another process requires performing a state save of the current process and a state restore of a different process. This task is known as a context switch.

Operations on Processes

Process Creation

Process Termination

Interprocess Communication

Reasons for process cooperation:

Shared-Memory Systems

Normally the operating system tries to prevent one process from accessing another process’s memory. Shared memory requires that two or more processes agree to remove this restriction.

Use buffer to share memory

Two kinds of buffer

bounded buffer can be implemented by a queue.

Message-Passing Systems

Naming

Synchronization

Communication between processes takes place through calls to send() and receive() primitives. There are different design options for implementing each primitive. Message passing may be either blocking or nonblocking— also known as synchronous and asynchronous.

Buffering

Whether communication is direct or indirect, messages exchanged by communicating processes reside in a temporary queue. Basically, such queues can be implemented in three ways:

Examples of IPC Systems

IPC: inter-process communication

An Example: Mach

All calls are based on message -- even system calls.

When a task is created, two special mailboxes are also created:

3 systems calls are need for message transfer:

When the mailbox is full, there are 4 strategy:

An Example: Windows XP

Communication in Client-Server Systems

Sockets

A socket is defined as an endpoint for communication. A socket is identified by an IP address concatenated with a port number.

Initialize a socket: assign a port with a number greater than 1024. All connections must be unique.

Remote Procedure Calls

In contrast to the IPC facility, the messages exchanged in RPC communication are well structured and are thus no longer just packets of data.

2 important concerns:

Remote Method Invocation