Docsity

Understanding OS Processes: Definition, States, Control Block, Scheduling, and IPC, Slides of Computer Science

Partial preview of the text

Download Understanding OS Processes: Definition, States, Control Block, Scheduling, and IPC and more Slides Computer Science in PDF only on Docsity!

3: Processes 1

OPERATING SYSTEMS

PROCESSES

3: Processes 2

What Is In This Chapter?

  • Process Definition
  • Scheduling Processes
  • What Do Processes Do?
  • Inter-process Communication

OPERATING SYSTEM

Processes

3: Processes 4

PROCESSES PROCESS STATE

  • New The process is just being put together.
  • Running Instructions being executed. This running process holds the CPU.
  • Waiting For an event (hardware, human, or another process.)
  • Ready The process has all needed resources - waiting for CPU only.
  • Suspended Another process has explicitly told this process to sleep. It will be awakened when a process explicitly awakens it.
  • Terminated The process is being torn apart.

3: Processes 5

PROCESS CONTROL BLOCK:
CONTAINS INFORMATION ASSOCIATED WITH EACH
PROCESS:

It's a data structure holding:

  • PC, CPU registers,
  • memory management information,
  • accounting ( time used, ID, ... )
  • I/O status ( such as file resources ),
  • scheduling data ( relative priority, etc. )
  • Process State (so running, suspended, etc. is simply

a field in the PCB ).

PROCESSES Process State

3: Processes 7

PROCESSES

Scheduling

Components

The CPU switching

from one process to

another.

3: Processes 8

Figure 4.

PROCESSES

Scheduling

Components

Ready Q

And

IO Q’s

3: Processes 10

SHORT TERM SCHEDULER (cont.)

  • Code to take a process off the ready queue and run that process (also called dispatcher). a) Always takes the first process on the queue (no intelligence required) b) Places the process on the processor.

This code runs frequently and so should be as short as possible.

MEDIUM TERM SCHEDULER
  • Mixture of CPU and memory resource management.
  • Swap out/in jobs to improve mix and to get memory.
  • Controls change of priority.

PROCESSES

Scheduling

Components

3: Processes 11

INTERRUPT HANDLER

  • In addition to doing device work, it also readies processes, moving them, for instance, from waiting to ready.

How do all these scheduling components fit together?

Fig 4.

PROCESSES

Scheduling

Components

Interrupt Handler

Short Term Scheduler

Short Term Scheduler

Long Term Scheduler

Medium Term Scheduler

3: Processes 13

Parent can run concurrently with child, or wait for completion.

Child may share all (fork/join) or part of parent's variables.

Death of parent may force death of child.

Processes are static (never terminate) or dynamic ( can terminate ).

Independent Execution is deterministic and reproducible. Execution can be stopped/ started without affecting other processes.

Cooperating Execution depends on other processes or is time dependent. Here the same inputs won't always give the same outputs; the process depends on other external states.

PROCESSES

Process

Relationships

3: Processes 14

This is how processes talk to each other.

There are basically two methods:

Shared memory (with a process "kick") -- fast/ no data transfer.

Message Passing -- distributed/ better isolation.

METHODS OF IMPLEMENTATION:
  • Direct or indirect - to process or mailbox.
  • Symmetric or asymmetric?
  • Buffering mechanism
  • Send by copy or by reference?
  • Fixed or variable size messages?
FUNCTIONALITY OF COMMUNICATION
LINKS:
  • How are the links formed?
  • How many processes on each link?
  • How many links per pair of processes?
  • Capacity - buffer space - can messages be enqueued.
  • Message formats and sizes
  • Uni- or bidirectional

PROCESSES

Interprocess

Communication

3: Processes 16

Other properties of Direct Communication:

  • Link established automatically (when send or receive requested.)
  • Only two processes in this form.
  • One link per pair of processes.
  • Generally Bi-directional
  • Receiver may not need ID of sender.

Disadvantage of Direct Communication:

  • The names of processes must be known - they can't be easily changed since they are explicitly named in the send and receive.

PROCESSES

Interprocess

Communication

3: Processes 17

INDIRECT COMMUNICATION
  • Processes communicate via a named mailbox rather than via a process name. Mechanism looks like this:

open( mailbox_name ); send ( mailbox_name, message ); receive ( mailbox_name, message);

  • Link is established if processes have a shared mailbox. So mailbox must be established before the send/receive.
  • More than two processes are allowed to use the same mailbox.
  • May cause confusion with multiple receivers - if several processes have outstanding receives on a mailbox, which one gets a message?

PROCESSES

Interprocess

Communication

3: Processes 19

Remote procedure call (RPC) abstracts

procedure calls between processes on networked systems.

Stubs – client-side proxy for the actual procedure on the server.

The client-side stub locates the server and marshalls the parameters.

The server-side stub receives this message, unpacks the marshalled parameters, and peforms the procedure on the server.

PROCESSES

Interprocess

Communication

3: Processes 20

WRAPUP

PROCESSES

We’ve looked in detail at how processes work. Specifically we’ve

  • Seen how they get scheduled (and studied schedulers in doing so),
  • Visited the actions that can be performed on objects,
  • Examined the extension of processes called threads,
  • Looked at how processes communicate with each other’