Fundamentals of Operating Systems: Understanding Processes and Interprocess Communication , Study notes of Operating Systems

An excerpt from the eecs 678 fundamentals of operating systems course taught at the university of california, berkeley during spring 2009. It covers the concepts of processes, their states, and the importance of interprocess communication (ipc). Various ipc mechanisms, including message passing and shared memory, and provides examples using pipes and unix domain sockets.

Typology: Study notes

Pre 2010

Uploaded on 09/17/2009

koofers-user-c1v
koofers-user-c1v 🇺🇸

10 documents

1 / 50

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EECS 678 Fundamentals of Operating Systems – Spring 2009 1
Chapter 3: Processes
What is a process ?
What is process scheduling ?
What are the common operations on processes ?
How to conduct process-level communication ?
How to conduct client-server communication ?
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32

Partial preview of the text

Download Fundamentals of Operating Systems: Understanding Processes and Interprocess Communication and more Study notes Operating Systems in PDF only on Docsity!

Chapter 3: Processes

n What is a process?

n What is process scheduling?

n What are the common operations on processes?

n How to conduct process-level communication?

n How to conduct client-server communication?

Process Concept

n Process

l (^) is a program in execution l (^) is an instance of a computer program being sequentially executed l (^) process execution must progress in sequential fashion l (^) process is also called a job

n Program Vs. process

l (^) program is a passive entity; process is an active entity l (^) program only contains text; process is associated with code, data, PC, heap, stack, registers, and other information l (^) program becomes a process when an executable file is loaded into memory l (^) same program executed multiple times will correspond to different process each time

Process State

n During execution, the process may be in one of the following

states

l (^) new – process is being created l (^) running – instructions are being executed l (^) waiting – waiting for some event to occur l (^) ready – waiting to be assigned a processor l (^) terminated – process has finished execution

n Each processor can only run one process at a instant.

Diagram of Process State

Process Control Block (PCB) (2)

CPU Switch From Process to Process

Ready Queue And Various I/O Device Queues

Representation of Process Scheduling

Context Switch

n A context switch is the process of storing and restoring the

state (context) of the CPU such that multiple processes can

share a single CPU resource

l (^) for time-shared or multiprogramming environments l (^) context of a process represented in the PCB l (^) context switch involves a state save of the current process, and a state restore of the process being resumed next l (^) switch from user to kernel mode or vice-versa is a mode switch

n Context-switch time is overhead

l (^) the system does no useful work while switching l (^) overhead depends on hardware support  (^) Sun UltraSPARC provides multiple banks of registers  (^) Intel x86 processors also provide some support

Process Creation

n Any process can create other processes during its execution

l (^) operating systems have a primordial process l (^) creating process called parent process l (^) new process called child process l (^) processes identified and managed via a process identifier ( pid )

n Resource sharing options

l (^) parent and children share all resources l (^) children share subset of parent’s resources l (^) parent and child share no resources

n Execution options

l (^) parent and children execute concurrently l (^) parent waits until children terminate

Process Creation Example on Unix

int main() { pid_t pid; /* fork another process / pid = fork(); if (pid < 0) { / error occurred / fprintf(stderr, "Fork Failed"); exit(-1); } else if (pid == 0) { / child process / execlp("/bin/ls", "ls", NULL); } else { / parent process / / parent will wait for the child to complete */ wait (NULL); printf ("Child Complete"); exit(0); } }

Process Creation

n Parent waiting for child process to finish

Interprocess Communication

n Communication within the same system.

n Processes may need to co-operate for several reasons

l (^) information sharing l (^) computation speedup l (^) modularity l (^) convenience

n Cooperating process can affect or be affected by other

processes

l (^) typically, by sharing data

n Cooperating processes need interprocess communication

( IPC )

Producer-Consumer Problem

n Common paradigm for co-operating processes

l (^) producer process produces information l (^) consumer process consumes the produced information

n Processes need synchronization

l (^) consumer cannot use information before it is produced by the producer

n Abstraction models

l (^) unbounded-buffer places no practical limit on the size of the buffer l (^) bounded-buffer assumes that there is a fixed buffer size