Chapter 2

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

A newly created process (still in the state new) at level i can have ______ links to processes at level i+1.

0 Child processes are created at runtime, not when a new process is established.

A process at level i in the process creation hierarchy can have ______ link(s) to processes at the next higher level i-1.

1 Except for Root, every process has exactly one parent process at the next higher level.

A process consisting of n ULTs is to be mapped onto a set of m KLTs. Which combination would not fully utilize available resources? a) n = m > 0 b) n > m = 1 c) m > n > 1 d) n > m > 1

c) m > n > 1 The n ULTs could not utilize all the m KLTs since each ULT is sequential and thus does not have any concurrent activities that could be mapped on more than one KLT

Multiple threads within a process _____. a) will always execute the same sequence of instructions b) must execute within disjoint parts of the shared program c) may execute different sequences of instructions within any part of the shared program

c) may execute different sequences of instructions within any part of the shared program. Each thread is an independent entity and can execute any sequence of instruction within the program regardless of any other thread.

Increasing the number of CPUs further from 3 to 4 will __________ speed of execution. a) decrease b) increase c) not affect

c) not affect Each process can only use one CPU and thus only 3 CPUs can be utilized.

If RL is implemented as a single list without priority levels and every new process is entered at the tail of RL then the following functions do not need to call the scheduler: 1) create() T or F? 2) destroy() T or F? 3) request() T or F? 4) release() T or F?

1) true The new process is inserted at the tail of RL. The calling process continues to run and create() does not need to call scheduler(). 2) true As long as the process cannot call destroy() on itself, the process will continue to run and scheduler() need not be called. 3) False When the resource is not available, the calling process is blocked and scheduler() must be called to select the next processes to run. 4) true The released resource is marked as free or is allocated to a waiting process, which is entered at the tail of RL. The calling process continues to run and scheduler() need not be called.

What is the minimum number of bits needed to represent the process_state field, if 3 states are supported: running, ready, and blocked?

2 bits can represent up to 4 states, which would be sufficient for the states running, ready, and blocked.

What is the minimum number of bits needed to represent the process_state field, if 6 states are supported: running, ready, blocked, new, suspended, and terminated?

3 bits can represent up to 8 states, which would be sufficient for the states running, ready, blocked, new, suspended, and terminated.

The list-free implementation requires ______ fields in the PCB instead of 2 to represent the parent/child relationships.

4 The original representation had the fields parent and children. The list-free implementation has the fields parent, child, older sibling, and younger sibling.

T or F? Memory and other fields are not replicated in the TCBs because the data is not needed by threads.

False All fields are needed by threads but all fields other than the CPU_state and thread_state can be shared by all threads.

Using n threads within a single process is more efficient than using n separate processes because _____.

False Both processes and threads can block independently from one another.

Using n threads within a single process is more efficient than using n separate processes because _____. only the threads can take advantage of multiple CPUs T or F?

False Both processes and threads can take advantage of multiple CPUs.

T or F? A request can be initiated by any process, regardless of the process's current state.

False Only a running process can initiate any actions.

T or F? A single RL could not be used with multiple CPUs.

False Starting with the highest-priority non-empty list, multiple processes can be marked as running in the RL. Ex: With 2 CPUs, the processes at level n and 7 in the above example could both be in the running state.

T or F? The PCB data structure could be reduced if a process could generate only one child at a time.

False The children field is a pointer to the first child in the list. The restriction would eliminate dynamic memory management but the same pointer to the first child process would still be needed.

T or F? When a blocked process p is suspended and the resource needed by p becomes available, p is moved to the ready state.

FALSE, p is suspended for a reason different from waiting for a resource. Thus p must remain in the suspended state until explicitly reactivated. Only then is the process moved to the ready state.

T or F? When a ready process p wishes to temporarily stop competing for the CPU, p moves itself to the suspended state.

FALSE, A process in the ready state is not running program code and so cannot perform any actions. Only the OS or p's creator (parent) can move p to the suspended state.

T or F? The PCB is created by the process when execution starts.

FALSE, The PCB is a data structure created and maintained only by the OS, not by the process itself.

T or F? The PCB becomes part of the program being executed by a process.

FALSE, The PCB is an independent data structure managed by the OS that is destroyed when the process terminates. The program remains unchanged.

A context switch for a currently running process p may be caused by _____. *some other process q T or F?

FALSE; The OS can take the CPU away from a running process p, or p can give up the CPU by requesting an unavailable resource. But some other process q cannot cause a context switch for process p.

T or F? When a newly created process p is ready to compete for the CPU, p moves itself from the new to the ready state.

FALSe, The purpose of the new state is to allow the OS to control how many processes are competing for the CPU and thus only the OS can cause a transition from new to ready.

T or F? In a multi-threaded process the PCB is replaced by multiple TCBs.

False A PCB is still needed because much of the information is shared by all threads within the process and need not be replicated in the TCBs.

T or F? The responsibility to close all files should rest with the programmer, not the destroy function.

False A process can be destroyed at unpredictable times and the programmer has no way of knowing when files would need to be closed (to prevent any loss of data not yet saved to disk).

T OR F? An application running on multiple physical CPUs must be modified in order to run correctly on a single CPU.

False A process can run on a dedicated CPU or with interruptions on a shared CPU. The context switches are transparent to the process, and the results are unaffected.

T or F? The initial value of the process_state field could be set to blocked if memory or some other critical resource is unavailable.

False A process enters the blocked state only when requesting an unavailable resource during execution. When a resource is unavailable at creation, the OS would postpone or decline the creation.

T or F? The release function may cause the calling process to stop running. To avoid penalizing the process for releasing a resource, a fairer approach would be not to call the scheduler as part of the release.

False The process waiting for the resource could have a higher priority than the running process and so should run as soon as the resource becomes available.

T OR F? The main purpose of virtual CPUs is to improve the performance of a system.

False Virtual CPUs allow processes to transparently share a physical CPU, generally at the cost of reduced speed. Virtual CPUs also allow processes to run different physical CPUs without code modification or recompilation.

T or F? A process can be blocked on more than one resource.

False When a process requests a resource that is not available, the process is blocked. The process will not be able to call request() again until the first resource becomes available and the process is allowed to run again.

T or F? The initial CPU state of a newly created process is NULL or undefined.

False The program counter must be set to the starting address. Also, the stack pointers must be set to point to the top of the stack. Other registers and flags are generally set to 0.

Valid or Invalid? running ➛ blocked ➛ ready ➛ blocked ➛ suspended.

Invalid. A process cannot go from ready to blocked because only a running process can request a resource.

new ➛ ready ➛ suspended ➛ blocked ➛ suspended. Valid or Invalid?

Invalid. A process that went from ready to suspended must return to ready rather than blocked.

Valid or Invalid? new ➛ ready ➛ running ➛ ready ➛ new.

Invalid. Only a newly created process is ever placed into the new state.

An OS uses a PCB to represent a process. T or F?

TRUE, The OS implements every process as a data structure called PCB, the process control block

T or F? When PCBs are allocated and freed dynamically, the overhead of the dynamic memory management could be reduced by reusing PCBs of destroyed processes.

TRue A PCB of a destroyed process could be reused by marking the slot in the pointer array with a new state (for example, "available"), instead of freeing the PCB data structure and setting the pointer to NULL.

The transition (running -> blocked) of a process p is caused by _____. *The OS *The process p itself *other process

The process p itself, p causes the transfer when requesting a currently unavailable resource.

T or F? With a single-unit resource, the state is just a Boolean.

TRUE The Boolean indicates whether the resource is free or allocated.

T or F? The transition of a process p from running to terminated can be caused by p itself.

TRUE, Completing all work or causing a fatal error causes p to transition from running to terminated.

A context switch for a currently running process p may be caused by _____. *the OS T or F?

TRUE, The OS may wish to let another process q use the CPU.

A context switch for a currently running process p may be caused by _____. *process p itself T or F?

TRUE, This context switch may occur when process p requests a currently unavailable resource.

T or F? Two processes can be executing the same program.

TRUE, A program can be executed multiple times simultaneously, each instance being a process. Each PCB has a separate program counter to keep track of each process' execution location in the program.

The transition (ready -> running) of a process p is caused by _____. *The OS *The process p itself *other process

The OS, Only the OS can decide when a process should continue to run.

The transition (running -> ready) of a process p is caused by _____. *The OS *The process p itself *other process

The OS, The OS may wish to let some other process use the CPU

T or F? Threads are faster to create and destroy than processes.

True A TCB is a much simpler data structure than a PCB and thus is faster to manage.

With RL implemented as a priority list, the range of priorities is [n1:n2], where n1 and n2 can be: T or F? n1 < 0, n2 > 0

True Depending on the implementation's needs, the range can start and end with any integer, including negative integers. Ex: [-5:5] provides 11 priority levels, where the positive range and the negative range could be given special significance, such as differentiate between interactive and background processes.

T or F? When a new process p is created, the scheduler could select p to run next.

True If p's priority is higher than or equal to the priority of p's parent, then p could be chosen by the scheduler.

T or F? Any process is either on the RL and in the ready or running state, or on a resource's waiting list and in the blocked state. To efficiently find on which lists p resides, additional information must be kept in the PCB.

True Only one RL, but potentially many waiting lists, exist in the system. To find the relevant list quickly, the PCB must maintain a pointer to the current list.

T or F?

True Such a call is generally known as a non-blocking call. The function returns a value to let the process know whether the resource has been allocated or not and to decide how to proceed.

Using n threads within a single process is more efficient than using n separate processes because _____. the threads share the same code and data T or F?

True The code and data do not have to be replicated n times.

With RL implemented as a priority list, the range of priorities is [n1:n2], where n1 and n2 can be: T or F? n1 = 0, n2 > 0

True The most common choice is to start the range with n1 = 0 and chose n2 to provide the desired number of priority levels. Ex: [0:7] provides 8 priority levels.

With RL implemented as a priority list, the range of priorities is [n1:n2], where n1 and n2 can be: T or F? n1 = 0, n2 = 0

True The range can be [0:0], in which case the priority list degenerates to a single linked list.

T or F? A waiting list can be implemented as a linked list where each element points to a PCB.

True The waiting list can be a linked list implemented outside of the RCB. But to avoid dynamic memory management, the links can also be distributed over the RCBs, similar to distributing child pointers over PCBs.

T or F? The calling process p could be preempted by some other process q when scheduler() is called from _________. destroy()

True destroy() could free up a resource r held by a destroyed process. If a process q with priority higher than p is blocked on r, then q could preempt p.

T or F? The calling process p could be preempted by some other process q when scheduler() is called from _________. request()

True if p blocks then some other process q is resumed.

T or F? The calling process p could be preempted by some other process q when scheduler() is called from _________. create()

True p could create q with a higher priority.

T or F? The calling process p could be preempted by some other process q when scheduler() is called from _________. release()

True release() could unblock a process q with a higher priority than p.

Valid or Invalid? suspended ➛ blocked ➛ suspended ➛ blocked ➛ ready ➛ running.

Valid. A suspended process goes back to blocked if the suspension occurred in the blocked state. Next, the process may be suspended again and later return back to the blocked state. When the resource becomes available, the process transitions to ready. Finally, from ready, the process may go into running.

With a multi-threaded process, each TCB maintains a separate copy of the thread state (running, ready, or blocked) but the PCB must also have a copy of the process state (running, ready, or blocked). a) Only with user-level threads. b) Only with kernel-level threads. c) Always. d) Never

a) Only with user-level threads. The kernel is aware of only the PCB, not the individual TCBs, and thus can only keep track of the process state as a whole in the PCB. The individual thread states are manipulated by the thread library independently of the process state.

3 processes are executing on 2 physical CPUs. Decreasing the number of CPUs from 2 to 1 will __________ speed of execution. a) decrease b) increase c) not affect

a) decrease All 3 processes will have to time-share the single CPU.

The list-free implementation is ________ the linked-list implementation. a) more time-efficient than b) less time-efficient than c) equally time-efficient as

a) more time-efficient than The main reason for the list-free implementation was to improve time-efficiency by avoiding the dynamic memory management needed for the linked lists.

Assume the release function is modified to handle resources with multiple identical units. Each call to release could reactivate ________. a) zero or more processes b) zero or one process

a) zero or more processes Release could reactivate any number of processes. Ex: 3 units are released.Case 1: Process at the head of waiting_list needs 4 units -- no process is reactivated.Case 2: Process at the head of waiting_list needs 3 units -- one process is reactivated.Case 3: The next 3 processes on waiting_list need 1 unit each -- all 3 processes are reactivated.

The children are assigned to a specialized OS process (Ex: the init process in Unix) as the new parent. a)Beneficial b)Detrimental

a)Beneficial This solution allows the child processes to continue executing while still under the control of another process responsible for their eventual termination.

When a process p is destroyed, the following choices can be made for p's children: The children are recursively destroyed along with p. a)Beneficial b)Detrimental

a)Beneficial This solution prevents the creation of any orphan processes.

Indicate which PCB fields may change during a process's lifetime. CPU_state a)May change b)Will not change

a)May change The CPU_state changes during every context switch.

Indicate which PCB fields may change during a process's lifetime. Children a)May change b)Will not change

a)May change The process can create and destroy multiple children at run time.

Indicate which PCB fields may change while a process is in the running state. children a)May change b)Will not change

a)May change The process can create and destroy multiple children at run time.

Indicate which PCB fields may change during a process's lifetime. open_files a)May change b)Will not change

a)May change The process can open and close any number of files during execution.

Indicate which PCB fields may change while a process is in the running state. open_files a)May change b)Will not change

a)May change The process can open and close any number of files during execution.

Indicate which PCB fields may change during a process's lifetime. process_state a)May change b)Will not change

a)May change The process_state keeps changing as the process requests resources or is moved to/from the CPU

Kernel calls are _____ to manage threads. a)needed only with KLTs b)needed only with ULTs c)always needed d)never needed

a)needed only with KLTs The only way to access and manipulate TCBs maintained within the kernel is via kernel calls.

The set of all PCBs could be implemented as a ________ A) 2-dimensional integer array, where the first dimension is the number of available PCB slots. b) 1-dimensional array of structures, where the array dimension is the number of available PCB slots. c) linked list of 1-dimensional integer arrays, where each list element is a PCB.

b) 1-dimensional array of structures, where the array dimension is the number of available PCB slots. *The fields of a PCB are of different data types and thus each PCB can be represented by a structure.

With a multi-threaded process, a context switch between threads is performed by the OS kernel. a) Only with user-level threads. b) Only with kernel-level threads. c) Always. d) Never.

b) Only with kernel-level threads. With kernel-level threads the kernel manages all TCBs and thus can switch between different threads.

Increasing the number of CPUs from 2 to 3 will __________ speed of execution. a) decrease b) increase c) not affect

b) increase Each of the 3 processes can now have a separate physical CPU.

When the CPU with floating operations is replaced with a CPU without floating point operations, then __________. A) the correctness of the operations may change b) speed of execution may change

b) speed of execution may change The virtual CPU software will implement the same operations as the hardware but the hardware implementation is likely to be faster.

The PCB contains an up-to-date copy of the CPU state of a process p _____ . a) when p's state is running b) when p's state is ready or blocked c) At all times

b) when p's state is ready or blocked At this point, p's PCB contains an exact copy of the CPU state at the point when p transitioned out of the running state. This CPU state is restored when p transitions back to the running state.

The children could be left without any parent. a)Beneficial b)Detrimental

b)Detrimental This solution could result in runaway processes (Ex: infinite loops), which would continue using resources but would be hard to detect and eliminate.

Indicate which PCB fields may change while a process is in the running state. CPU_state a)May change b)Will not change

b)Will not change The CPU_state is copied into the CPU when the process starts running and is not updated until the process stops again.

Indicate which PCB fields may change during a process's lifetime. parent a)May change b)Will not change

b)Will not change The parent is the creator of the current process and by definition cannot change.

Indicate which PCB fields may change while a process is in the running state. parent a)May change b)Will not change

b)Will not change The parent is the creator of the current process and by definition cannot change.

Indicate which PCB fields may change while a process is in the running state. process_state a)May change b)Will not change

b)Will not change The process_state is set to "running" when the process starts running and changes to "ready" or "blocked" only when the process stops running.

When a process p is moved from the current state (running, ready, or blocked) to the suspended state, then upon reactivation, ________. a) P must be moved back to the same state where the suspension occurred b) P can always safely be be moved to the ready state c) P is moved to either the ready or the blocked state

c) P is moved to either the ready or the blocked state !! If the suspension occurred in the blocked state then p must go back to the blocked state. If the suspension occurred in the running or ready state then p must go to the ready state.

What would be the most likely outcome if a process called destroy(self): a) The process and all descendants would terminate safely. b) The function would destroy all descendants but not the process itself. c) The process would crash.

c) The process would crash. The destroy function is executing as part of the current process. Releasing all memory, resources, PCB, and closing all files would prevent the process from completing the entire destroy function.

Each link in the process creation hierarchy corresponds to a ________. a) pointer directed toward the Root b) pointer directed away from the Root c) bidirectional pointer

c) bidirectional pointer Both directions must be represented so that any process can reach the parent and vice versa.

Reusing PCBs of destroyed processes rather than freeing the data structures is more time-efficient __________. a) and also more space-efficient b) and equally space-efficient c) but less space-efficient

c) but less space-efficient The PCBs are never freed and thus the total space required corresponds to the maximum number of PCBs ever existing concurrently, rather than just the average.

The transition (blocked -> ready) of a process p is caused by _____. *The OS *The process p itself *other process

other process, p is waiting for a resource held by some other process q. The release of the resource by q causes the transition of p back to ready.

Adding a new child process with the list-free implementation uses _____ the linked-list implementation. a) less memory than b) more memory than c) the same amount of memory as

c) the same amount of memory as Two pointers are required per child with either implementation. With a linked-list, the 2 pointers are in a linked-list node. With the list-free implementation, the 2 pointers are added to the PCB. So the memory usage is the same.

The release function always reactivates ________. a) exactly one waiting process b) zero or more processes c) zero or one process

c) zero or one process If the waiting list is not empty then the next process is reactivated, otherwise no process is reactivated.

What would be the most space-efficient data type to represent the process_state in C?

char Each character is a single byte or 8 bits and can represent up to 2^8 different states.


Set pelajaran terkait

Ch. 15 Cardiovascular System Quiz

View Set

Chapter 11 - Where Did We Come From?

View Set

Ch 21 Respiratory Care Modalities

View Set