thursday, june 08, 2006 the number of unix installations has grown to 10, with more expected. the...

Post on 19-Dec-2015

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Thursday, June 08, 2006

The number of UNIX installations has grown to 10, with more expected.

The UNIX Programmer's Manual, 2nd Edition, June, 1972

Completion of I/O triggers an interruptHardware Trap:

Division by zero Invalid memory access

Request for OS service Trap/System call/Monitor call

Protection

Dual Mode Operation User mode Kernel mode

Mode bit (0/1) (MS-DOS did not have it)System call (switches from user mode to

kernel mode)Privileged instructions should be

executed in kernel mode only

Protection

Changing mode bit?

I/O Protection

User cannot issue I/O instructions directly

Changes to interrupt vector?

Memory Protection

Memory Protection

Memory Protection

Changes to base and limit registers?

CPU Protection

E.g. Infinite loop executed by a process

CPU Protection

Timer handler?

Process :Program in execution

Associated state (PC, SP, registers etc)

Address space

ProcessesThe Process Model

Multiprogramming of four programsConceptual model of 4 independent, sequential processesOnly one program active at any instant

Logical program counter

Execution order not reproducible

Process creation• System initialization

• User request to create a new process

Process Termination

Conditions which terminate processes

1. Normal exit (voluntary)

2. Error exit (voluntary)

3. Fatal error (involuntary)

4. Killed by another process (involuntary)

Process Hierarchies

Parent creates a child process, child processes can create its own process

Forms a hierarchy UNIX calls this a "process group"

Windows has no concept of process hierarchy all processes are created equal

As a process executes, it changes state new: The process is being created running: Instructions are being executed waiting: The process is waiting for some event to occur ready: The process is waiting to be assigned to a

processor terminated: The process has finished execution

Process States

ps in Unix

Background processes

Process Control Block (PCB)

CPU Switch From Process to Process

Process Scheduling Queues

Job queue – set of all processes in the systemReady queue – set of all processes residing in main

memory, ready and waiting to executeDevice queues – set of processes waiting for an I/O

deviceProcesses migrate among the various queues

Ready Queue And Various I/O Device Queues

Representation of Process Scheduling

I/O parallelism:

overlap execution: make 1 CPU into many (Real parallelism: > 1 CPU (multiprocessing))

Completion time:

B’s completion time = 100s (A + B) So overlap

Why processes? Speed

emacs (Wait for input) (Wait for input)

gcc

A B

A

B

20 s80 s

Completion time for B? A?10 s

Context Switch

When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process

Context-switch time is overhead; the system does no useful work while switching

Time dependent on hardware support

Passing of Parameters As A Table

Process Creation (Cont.)

Address space Child duplicate of parent Child has a program loaded into it

UNIX examples fork system call creates new process exec system call used after a fork to replace

the process’ memory space with a new program

top related