1/33
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Process
a running programme. a process is active/dynamic whereas a program is a passive entity
What does a process consist of?
Process text (code of the program)
program counter (the address of the next instruction to be executed)
process stack (temporary data eg local variables, return addresses etc)
data section (global variables)
What must an operating system be able to do at minimum?
Create: a new process
Destroy: /terminate a process
Wait: or pause a process until some event occurs
Suspend/resume: like wait but more explicitly evoked
Status report: information about a process eg how long it has run for, how much memory has been allocated to it etc
What is the state of a process?
the state of a process if defined (in part) by the current activity of that process
Name and describe the five possible states of process activity
New: the process is being created
Running: Instructions are being executed
Blocked: (also called waiting) process is waiting for some event to occur
Ready: The process is waiting to be assigned to a processor
Termination: The process has finished execution
Sketch a diagram of process life cycle
New → Running → Blocked → Ready → Termination
If process A initiates process B then:
process A is the Parent
Process B is the Child
PID
Process identification number, all processes have a unique PID
What is does an operating system do ?
provides an interface between users and the computer’s hardware.
allocates resources: it gives access to the CPU, RAM, mass storage, etc., and makes efficient use of resources
The fork() function creates a child process. What does it return?
the child’s PID to the parent, and 0 (zero) to the child
What does getpid() do?
returns value of the process PID
What does getppid() do?
Returns the value of the processes parent PID
execlp() function
allows you to overlay child process with another program
When might process termination occur?
the process executes its last instruction and asks OS to delete it
Parent terminates child process because, subproc has exceeded allocated resources or task assigned to subproc is no longer required
Signals
a form of communication from one processe to another eg kill()
signal()
with signal() we can send a signal that tells the process to preform a specific action when it recieves a SIGUSR1 OR SIGUSR2 (user defined signals) signal
IPC
inter process communication, provides a logical communication link via a message passing facility with 2 basic operations: send and recieve message
Two processes that are executing on the same computer can be either independent or cooperating. Explain what is meant by independent in this context
They cannot affect/ be affected by the execution of the other
Two processes that are executing on the same computer can be either independent or cooperating. Explain what is meant by cooperating in this context
They can be affected or affect by the execution of the other
Name 4 advantages facillitated by allowing process communication
Information sharing
Modularity (different procs might be dedicated to different system functions)
Convenience
Computational speed (on a multi processing system, tasks are sub divided and executed at the same time on different processors
Why do cooperating processes require communication?
to share data and sync their actions
What does the producer-consumer model describe?
Communication between cooperative processes
One process might have information it wants to produce for consumption by another process. this can be done with a mutual buffer so that the producer writes to the buffer and the consumer reads from it
Bounded buffer
There is a strict limit on the size of the buffer. If the buffer is full then the produced must wait until the consumer removes some data
Unbounded buffer
There is no size limit on the buffer. The prodcucer can produce and write to the buffer for as long as it wants to
Name and describe the 2 ways a buffer may be implemented
physically: by a set of shared variables (eg shared memory addresses). Implemented by programmer
Logically: by message passing via an interprocess communication facility. implemented by OS
Disadvantages of Direct Communication IPC
processes must have details of each other before communicating
only 1 link per pair of processes
one 2 processes can communicate at a time
Disadvantages and solutions for Indirect Communication IPC
Disadvantage: If one process shares data through a shared mailbox with multiple processes, which process gets to read the data?
Solution:
-The Mailbox is “owned” by only one proc. Then several procs can
write to it, but only one can read.
- Mailboxes are owned only by Operating System. Permissions then
granted to process to create and delete mailboxes, and to send or recieve messages
Symmetric vs Aysmmetic addressing
Symmetric → both processes need to know each others ID (direct communication) / name of shared mailbox (indirect)
Aysemetric → only the sender needs to know the recievers ID (direct)/ name of mailbox (indirect)
Indirect communication
number of ports (Mailboxes) in the system.
Each has a unique ID.
• For procs to communicate they just need to know the name of the
shared mailbox.
More that two procs can share a mailbox.
Two procs may share more than one mailbox.
pipe()
A pipe is a means of communication. It is a form of symetric direct communication
Using the pipe(fd) function, one process creates a pipe. Here fd is
a int array with two elements.
• To put a message into the pipe, write to name[1]
• To read a message from the pipe, read from name[0]
Program Counter (PC)
Tells the OS which line of code is being executed