Processes Flashcards

0
Q

Describe what a process control block or task control block is

A
  • This is basically all the information related to a process that the operating system needs to save in order to be able to properly restore process to working state after suspending them.
  • This includes program counter, registers, state of current process, how much time it’s been running, what i/o devices are opened by the process, etc.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Describe what a process is.

A
  • A process is basically a program in execution.
  • It’s the basic piece of execution in operating systems. os must efficiently assign resources to processes. They usually do this by quickly switching between different processes.
  • A process consists of the following in memory:
    1) Text section containing code to be executed.
    2) Stack containing temporary data associated with each function call.
    3) Heap containing data allocated dynamically by program
    4) Data containing global variables.
  • A process consists of the following on cpu:
    1) Program counter indicating next instruction to run
    2) Registers containing data to be used by instructions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe how process scheduling works.

A
  • Operating systems often have multiple process queues containing the current processes it have to work with.
  • This includes:
    1) Job queue containing all current processes
    2) Ready queue containing all processes ready to run
    3) I/O device queues containing processes waiting for device, one for each device.
  • The process of selecting processes to run is done by the scheduler. There are a few types:
    1) Long term scheduler selects which jobs on disk to load onto memory. Long term scheduler usually have to select a good mix of cpu-bound and i/o bound processes for good performance. This scheduler doesn’t have to be super fast since it doesn’t run often.
    2) Short term scheduler selects which process in memory should have cpu time. This job runs once every few 100ms and should be really fast
    3) Midterm scheduler selects processes to swap in and out of memory, perhaps trying to achieve good mix of i/o and cpu bound processes or changes in memory need.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe process creation process and some variations in how it can be done.

A
  • Processes are usually organized as a tree, with parent starting their child processes .
  • All these processes also have pid associated.
  • There are variations in how parent and child process use resources. Some os make child and parent share cpu, memory, and open file resources, while others have each process ask for their own resources.
  • There are also variations in what happen after parent create children. It can either wait or just continue execution.
  • There are also variations in what program gets loaded in child process. Some has copy of parent, others have new program loaded.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe child termination process.

A
  • A process can terminate either by exitting normally or with some status. Alternatively, it can be killed by parent process.
  • There are questions on what happen to children processes once the parent exit.
  • In unix, parents usually call wait() on children processes and exit only after children exit. The call to wait() is important because after children exit, their resources are deallocated but they are still in process table. The call to wait removes it process from process table. If this call is never made, the process is called a zombie process.
  • In unix, children process usually gets assigned to init if parent does not call wait on it and exit. Init periodically call wait.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe interprocess communication.

A
  • There are 2 main ways processes can communicate:
    1) Shared memory
    2) Message passing
  • In shared memory model, one process ask operating system to make some part of its memory available to another process. Everything in that memory area is then shared between processes.
  • There are concurrency issues with this model, but communication is usually fast.
  • In message passing model, processes communicate by message. There are a few variations of this:
    1) Process may pass message to each other directly or by a mailbox. A mailbox system is more robust because pid of process can change independently. Mailbox can either be created by process or by os as well.
    2) Process may block or not block while passing message. If message should be passed without blocking, there should be a buffer for message to reside.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe mechanisms through which process on different systems communicate.

A

There are 3 main ways through which processes on different machines can communicate:

1) Sockets. In this model, a process acts as server and usually listen on some well known port. A client open a socket to this well known port and is given a port with number of 1024 or higher to communicate. Message passed is just byte streams. It’s up to client how to organize the message.
2) Remote procedure call. In this model, client and server has stubbed local functions. Client call the local stubbed function and the stubbed function package parameter, convert parameter into machine-independent format before calling remote server. Stubbed function on remote server then convert parameters into machine specific parameters before calling local functions and return.
3) Pipes. There are two types of pipes. Ordinary pipes and named pipes. Ordinary pipes exist between two running processes, usually parent and child. Named pipes, on the other hand, exist independent of processes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly