Zybook Ch2: Processes, Threads, and Resources Flashcards

1
Q

What is a process?

A

an instance of a program being executed by an OS

Ex: the OS creates a new process when a user opens a new application

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

What is the OS organized as?

A

The OS is organized as a collection of processes

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

How does the OS keep track of each process?

A

Process Control Blocks (PCB)

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

What is a process control block (PCB)?

A

A data structure that holds information for a process, including the current instruction address, the execution stack, the set of resources used by the process, and the program being executed. The PCB is the concrete representation of a process.

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

What are the 3 basic states that are implemented by most OSs for a process?

A

Running state (running)

Ready state (ready)

Blocked state (blocked)

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

What is the running state?

A

When the process has all necessary resources and the CPU is actively executing the program’s instructions.

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

What is the ready state?

A

When the process has all necessary resources to run but the CPU is currently unavailable.

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

What is the blocked state?

A

When the process is waiting on a currently unavailable resource.

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

What is the new state?

A

State a newly created process is placed into before the process is allowed to compete for the CPU

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

What is the terminated state?

A

The state the process is placed into when execution can no longer continue but the PCB has not been deleted.

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

What is the suspended state?

A

The state the process is placed into even though the CPU and all resources are available?

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

What is a context switch?

A

The transfer of control from one process to another?

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

What is the CPU state?

A

All of the intermediate values held in any CPU registers and hardware flags at the time of interruption.

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

What is a physical CPU?

A

The real hardware instance of a CPU

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

What is a virtual CPU?

A

A CPU the process thinks is available only to itself. Occurs when multiple processes run on one physical CPU using time sharing

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

What is a virtual CPU in relation to the physical CPU?

A

it can be an abstraction of the physical CPU or it can be a software that emulates the behavior of a different CPU

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

What are the benefits of virtual CPUs?

A

Multi-user support, multi-cpu transparency, portability

18
Q

What is multi-user support?

A

Multiple users, each represented by one or more separate processes, can share the same machine without being aware of each other.

19
Q

What is multi-CPU transparency?

A

An application written to utilize multiple CPUs will run correctly, although perhaps more slowly, if only one CPU is available.

20
Q

What is portability for virtual CPUs?

A

An application compiled for one type of CPU can run on a different CPU without being modified or even recompiled.

21
Q

What are the benefits of using multiple cooperating processes?

A

1) The interfaces between the processes are simple and easy to understand.
2) Each process can be designed and studied in isolation.
3) The implementation reduces idle time by overlapping the execution of multiple processes.
4) Different processes can utilize separate CPUs, if available, thus speeding up the execution.

22
Q

What are the fields for a generic PCB?

A

CPU_state, process_state, memory, scheduling_information, accounting_information, open_files, other_resources, parent, children

23
Q

What is the CPU_state field?

A

When p is stopped, the current state of the CPU, consisting of various hardware registers and flags, is saved in this field. The save information is copied back to the CPU when p resumes execution.

24
Q

What is the process_state field?

A

Stores p’s current state. Ex: Running, ready, or blocked.

25
Q

What is the PCB memory field?

A

Describes the area of memory assigned to p. In the simplest case the field would point to a contiguous area of main memory. In systems using virtual memory (to be introduced in a later chapter) the field could point to a hierarchy of memory pages or segments.

26
Q

What is the scheduling_information field?

A

Contains information used by the scheduler to decide when p should run. The information typically records p’s CPU time, the real time in the system, the priority, and any possible deadlines.

27
Q

What is the accounting_information field?

A

Keeps track of information necessary for accounting and billing purposes. Ex: The amount of CPU time or memory used.

28
Q

What is the open_files field?

A

Keeps track of the files currently open by the process.

29
Q

What is the other_resources field?

A

Keeps track of any resources, such as printers, that p has requested and successfully acquired.

30
Q

What is the parent field?

A

Every process is created by some other running process. The parent process of a process p is the process that created p. The parent field records the identity of p’s parent.

31
Q

What is the children field?

A

A child process c of process p is a process created by p. Process p is c’s parent. The identity of every child process c of p is recorded in the children field.

32
Q

How is each PCB implemented and why?

A

Each PCB is implemented as a heterogeneous data structure because they are composed of different data types?

33
Q

What are the two ways to organize all PCBs?

A

1) An array of structures. The PCBs are marked as free or allocated, which eliminates the need for any dynamic memory management. The main drawback is a lot of wasted memory space to maintain a sufficient number of PCB slots.
2) An array of pointers to dynamically allocated PCBs. The pointer array wastes little space and can be made much larger than the array of structures. The drawback is the overhead of dynamic memory management to allocate each new PCB and to free the memory when the process terminates.

34
Q

Why are linked lists avoided in OS?

A

They require dynamic memory management, which is costly.

35
Q

How are PCBs organized without linked lists?

A

The links are distributed over the child PCBs such that each points to the immediate younger sibling and immediate older sibling. The original 2 fields, parent and children, in the PCB of a process p are replaced by 4 new fields:

  • parent: points to p’s single parent as before
  • first_child: points to p’s first child
  • younger_sibling: points to the sibling of p created immediately following p
  • older_sibling: points to the sibling of p created immediately prior to p
36
Q

What is the waiting list?

A

It is associated with every resource and contains all processes blocked on that resource because the resource is not available.

37
Q

What is the ready list (RL)?

A

A list containing all processes that are in the ready state and thus are able to run on the CPU. The RL also includes the currently running process.

38
Q

What is a process creation hierarchy?

A

A graphical representation of the dynamically changing parent-child relationships among all processes. The process creation hierarchy changes each time a process is created or destroyed.

39
Q

What is the create process function?

A

create() is a function that allocates a new PCB, fills the PCB entries with initial values, and links the PCB to other data structures in the system

40
Q

What are the 8 steps of the create process function (create())?

A

1_ A new PCB is allocated. The PCB is uniquely identified by a pointer or an array index p.

2) The fields cpu_state, memory, scheduling_information, and accounting_information are filled using the initial values supplied to the function as parameters.
3) Assuming the state transition diagram consists of only the three states, running, ready, and blocked, the process state field is set to ready.
4) The parent field of p is set to point to self, which is the calling process and thus the parent of p.
5) In turn, p is inserted into the calling process’s list of children as a new child.
6) The remaining fields are set to NULL, since at creation p has no children, no open files, and no other resources.
7) p is inserted into the RL.
8) The scheduler function is called to select the process to run. Depending on the priorities of the two processes, the scheduler could choose to start the new child process p or to continue the execution of p’s parent process.

41
Q

How are processes destroyed?

A

destroy(p). The destroy process function destroys a process by freeing the PCB data structure and removing any references to the PCB from the system.

42
Q

What are the steps of destory(), the destory process function?

A

1) After calling destroy(c) on all child processes, remove p from either the RL (when p is ready) or from the waiting list of a resource (when p is blocked).
2) Remove p from the list of children of the calling process.
3) Release all memory and other resources, close all open files, and deallocate the PCB.
4) Call the scheduler to select the next process to run. The call must be made outside of the destroy(p) function to guarantee that the scheduler executes only once, after the entire hierarchy of processes has been destroyed, rather than as part of every recursive call to destroy(c).