Operating Systems CS 414: Processes and Context Switching at University of Virginia - Prof, Study notes of Operating Systems

This document from the university of virginia's cs 414 operating systems course explores processes, context switching, and the saving and restoring of process states. Topics include the importance of saving the program counter, processor status word, and registers, as well as the options for memory protection. The document also covers forking, creating independent and cooperating processes, and atomic operations.

Typology: Study notes

Pre 2010

Uploaded on 07/29/2009

koofers-user-q8a
koofers-user-q8a 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 414 : Operating Systems
UNIVERSITY OF VIRGINIA
Department of Computer Science
Fall 2005
Topic 2: Processes
Context switching: saving the state (to where?) and restoring it
What gets saved? Everything that next process could damage:
program counter, processor status word, registers.
all of memory? all disks? all the stuff on tape?
options for memory contents: a) trust next process b) move everything to disk (Alto sys-
tem), c) memory protection
Why tricky?
All machines provide some special hardware support.
Motorola 68000: hardware just moves PC and status word to the stack. OS then handles
rest of state itself. Must be done carefully. Why?
Intel 432: hardware does all state saving and restoring into process control block, and
even dispatching. Desirable?
Ugly issue of performance: sometimes making dirty shortcuts.
Birth of a process: creating it from scratch:
Allocate memory
Load code and data into memory.
Create (empty) call stack.
Create and initialize process control block.
Make process known to dispatcher.
2.1
pf3

Partial preview of the text

Download Operating Systems CS 414: Processes and Context Switching at University of Virginia - Prof and more Study notes Operating Systems in PDF only on Docsity!

CS 414 : Operating Systems

UNIVERSITY OF VIRGINIA

Department of Computer Science

Fall 2005

Topic 2: Processes

Context switching: saving the state (to where?) and restoring it

What gets saved? Everything that next process could damage: program counter, processor status word, registers. all of memory? all disks? all the stuff on tape? options for memory contents: a) trust next process b) move everything to disk (Alto sys- tem), c) memory protection

Why tricky?

All machines provide some special hardware support. Motorola 68000: hardware just moves PC and status word to the stack. OS then handles rest of state itself. Must be done carefully. Why? Intel 432: hardware does all state saving and restoring into process control block, and even dispatching. Desirable?

Ugly issue of performance: sometimes making dirty shortcuts.

Birth of a process: creating it from scratch: Allocate memory Load code and data into memory. Create (empty) call stack. Create and initialize process control block. Make process known to dispatcher.

Forking: copying existing process Make sure process to be copied isn’t running and has all state saved. Make a copy of code, data, stack. Copy PCB into new PCB. Make process known to dispatcher. What’s missing?

Independent process: neither affect nor affected by the rest of the universe. its state is not shared in any way with other processes deterministic reproducible scheduling does not affect the result There are many different ways in which a collection of independent processes might be exe-

cuted on a processor. How often are processes independent?

Cooperating processes: cooperating processes share state. May or may not actually be ‘‘cooperating’’. nondeterministic : depends on relative execution sequence. irreproducible. example: one process writes ‘‘ABC’’ to the monitor, another writes ‘‘CBA’’.

Why allow processes to cooperate? want to share resources: one computer, many users. one file of checking account records, many tellers. want to do things faster: read next block while processing current one. divide job into sub-jobs, execute in parallel. Basic assumption for cooperating process systems is that the order of some operations is ir-

relevant; certain operations are independent of certain other operations. Only a few things matter: example: A = 1; B = 2; has same result as B = 2; A = 1;