Operating Systems Finals

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/667

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

668 Terms

1
New cards

An operating system is responsible for which task?

loading applications into memory

2
New cards

A privileged instruction executed in user mode

changes the mode bit to kernel mode

3
New cards

For time-sharing to work between applications, which technique should be used?

 

Interrupt

4
New cards

Improving system performance is achievable with which solution?

Additional physical CPUs

5
New cards

Which one is not True?

Time-sharing is possible without interrupts

6
New cards

The concept of unification and simplification by combining simple objects into more complex objects is referred to as

Abstraction

7
New cards

______ determines the cause of the interrupt and invokes the appropriate kernel function to provide the response

Interrupt Handler

8
New cards

Request from an application for an OS service

System Call

9
New cards

Which one is Not True?

A release resource function has been called and the waiting list is empty. As a result, the resource is marked as allocated.

10
New cards

An application process stops executing. Which PCB field maintains hardware registers and flags that will be used when the application process resumes?

CPU_state

11
New cards

What happens first when a process is destroyed?

 

Child processes are destroyed.

12
New cards

Which is Not True?

A process is in ready state when both CPU and necessary resources are available

13
New cards

Two concurrent applications, a1 and a2, execute the sequences of instructions (j1, j2, j3) and (k1, k2, k3), respectively. Execution switches between the applications whenever a timeout interrupt occurs or when one application terminates. If a1 starts, and interrupts occur after instructions k1 and j1, then what is the order in which the 6 instructions will execute?

 

j1, k1, j2, j3, k2, k3

14
New cards

This series of process state transitions is valid.

new ➛ ready ➛run ➛ suspended ➛ ready ➛ run➛ terminated

True

15
New cards
<p><span>Processes p1 and p2 execute on a system with a single CPU and two identical I/O devices. Each process executes a compute-bound phase followed by an I/O-bound phase. The system uses multiprogramming without time-sharing. The following table shows the lengths of each phase.</span></p>

Processes p1 and p2 execute on a system with a single CPU and two identical I/O devices. Each process executes a compute-bound phase followed by an I/O-bound phase. The system uses multiprogramming without time-sharing. The following table shows the lengths of each phase.

p1 starts first at time 0.

Without multiprogramming, the computation terminates at time 160
You add everything straight:
40 (p1 compute) + 50 (p1 I/O) + 30 (p2 compute) + 40 (p2 I/O) = 160

With multiprogramming, the computation terminates at time 110

total time = p1 compute + max(p1 I/O, p2 compute + p2 I/O)

So:

  • p1 compute = 40

  • p2 compute + I/O = 30 + 40 = 70

  • p1 I/O = 50

Now take max of overlapping parts:
max(50, 70) = 70

Then:

total time = 40 + 70 = **110**

<p>p1 starts first at time 0.</p><p>Without multiprogramming, the computation terminates at time&nbsp;<strong>160</strong><br>You <strong>add everything straight</strong>:<br>→ <code>40 (p1 compute) + 50 (p1 I/O) + 30 (p2 compute) + 40 (p2 I/O) = 160</code><br><br>With multiprogramming, the computation terminates at time <strong>110</strong></p><p><strong>total time = p1 compute + max(p1 I/O, p2 compute + p2 I/O)</strong></p><p>So:</p><ul><li><p class="">p1 compute = 40</p></li><li><p class="">p2 compute + I/O = 30 + 40 = 70</p></li><li><p class="">p1 I/O = 50</p></li></ul><p class="">Now take max of overlapping parts:<br>→ <code>max(50, 70) = 70</code></p><p class="">Then:</p><p class=""><span data-name="arrow_right" data-type="emoji">➡</span> <code>total time = 40 + 70 = **110**</code></p>
16
New cards

Which of the following instructions should be non-privileged?

 

Issue a trap instruction

17
New cards

Which one is NOT contained in process control block (PCB)?

resource status

18
New cards

The  linked-list  implementation for PCB is more time-efficient than the list-free implementation.

False

19
New cards

Which one is Not True?

 

 

Scheduler() call must be made inside of the destroy() function to guarantee that the scheduler executes multiple times.

20
New cards

Which is Not True?

 

To close files should be the responsibility of the programmer, rather than being performed automatically as part of the destroy function

21
New cards
<p><span>Process 8 creates a child process, process 0. Complete the resulting PCB tables.</span></p>

Process 8 creates a child process, process 0. Complete the resulting PCB tables.

knowt flashcard image
22
New cards

3 independent processes are executing on 2 physical CPUs. Decreasing the number of CPUs from 2 to 1 will decrease speed of execution.

True

23
New cards

Which technique improves system resource utilization by holding active programs in memory while the programs wait for I/O completion or for an event to take place?

Multiprogramming

24
New cards

An application process is in a running state. Which PCB field cannot change?

Parent

25
New cards

Transferring control of the CPU from one process to another is  _________

context switch

26
New cards

A test-and-set machine instruction has a form of TS(R, x) where R is a register and x is a memory location. What operations are performed with R and x?

 

Copy x to R, then set x to 0.

27
New cards

Which one is Not True?

In Monitor, a conditional variable can take any integer value

28
New cards

When a process repeatedly executes a loop while waiting for a condition to change, CPU resources are wasted. This behavior is called _____.

 

busy-waiting

29
New cards
<p><span>Two processes are executing the computations A through F.&nbsp; Please insert P and V operations into the code to enforce the prescribed order. (Hint: use 3 semaphores)</span><br>&nbsp; &nbsp;<span><u>P1</u></span>&nbsp; &nbsp; &nbsp; &nbsp;<span><u>P2</u></span></p><p>&nbsp; &nbsp; A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;C</p><p>&nbsp; &nbsp; B&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;D</p><p>&nbsp; &nbsp; E&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;F<br><br><span>The computations must be executed in the order given by the following precedence graph. (start A, end F)</span></p><p><br></p>

Two processes are executing the computations A through F.  Please insert P and V operations into the code to enforce the prescribed order. (Hint: use 3 semaphores)
   P1       P2

    A         C

    B         D

    E         F

The computations must be executed in the order given by the following precedence graph. (start A, end F)


  • A must complete before B and C start

  • B must complete before E starts

  • C must complete before D starts

  • D and E must both complete before F starts

Let’s name three semaphores:

  • S1: signals completion of A, allowing B and C to proceed

  • S2: signals completion of B and C, allowing E and D to proceed

  • S3: signals completion of D and E, allowing F to proceed

Initialization:

semaphore S1 = 0;  // unlocks B and C after A
semaphore S2 = 0;  // unlocks D and E after B and C
semaphore S3 = 0;  // unlocks F after D and E

Process P1:

A;
V(S1);         // signal A is done, B and C can start

P(S1);         // wait for A
B;
V(S2);         // signal B is done, E can start

P(S2);         // wait for D and E to finish
E;
V(S3);         // signal E is done

Process P2:

P(S1);         // wait for A
C;
V(S2);         // signal C is done, D can start

P(S2);         // wait for B and C
D;
V(S3);         // signal D is done

P(S3);         // wait for D and E
F;

  • P(x) is the "wait" operation (decrements and waits if 0)

  • V(x) is the "signal" operation (increments, releasing any waiting processes)

30
New cards

The implementation of P(s), where s is a general semaphore, avoids busy-waiting by _____.

blocking the invoking process

31
New cards

When the value of s in a general semaphore implementation is less than 0, s corresponds to the _____.

 

number of blocked processes

32
New cards

Which one is Not True about Monitor?

 

The monitor operation c.signal blocks the invoking process

33
New cards

Which one is Not True about monitor implementation of the bounded-buffer problem?

 

 

The producer must wait when full_slots = 0

34
New cards

A monitor with priority waits keeps blocked processes sorted _____.

by priority

35
New cards

In the readers-writers problem, _____ enter the critical section concurrently, but only one _____ can enter at a time.

 

readers, writer

36
New cards

Which one is Not True about dining-philosopher problem (given 5 philosophers) ?

 

When p[4] is eating then p[0] or p[2] can eat concurrently.

37
New cards

The solution to the dining-philosophers problem where all philosophers pick up the left fork first may lead to _____.

deadlock

38
New cards

A solution to the dining-philosophers problem where both forks must be picked up at the same time in a critical section prevents _____ but may lead to _____.

deadlock, a concurrency violation

39
New cards

In the monitor solution to the dining-philosophers problem, forks are implemented using _____.

 

state transitions

40
New cards

With readers-writers Monitor, please determine the order in which all requests currently in the system pass through the CS.

w1, (r1, r2, r3, r4), w2

41
New cards
<p><span>Following figure shows a monitor model for dining philosophers problem. Please find the right code for (1) and (2) respectively.</span></p>

Following figure shows a monitor model for dining philosophers problem. Please find the right code for (1) and (2) respectively.

(1) eat[i].wait (2) eat[i].signal

42
New cards

A situation where multiple processes are blocking each other indefinitely

Deadlock

43
New cards

A situation where a process not attempting to enter a CS prevents other processes from entering the CS

Lockout

44
New cards

A situation where a process can repeatedly enter the CS while other processes are waiting to enter

Starvation

45
New cards

The requirement that only one process may execute in a CS

Mutual Exclusion

46
New cards

Three processes execute the following sequences concurrently:

p1:

P(s2)
A
V(s2)

p2:

P(s2)
B
V(s2)

p3:

P(s1)
C
V(s2)


If s1 = 1 and s2 = 0, in which order can the statements A, B, and C execute.

 

C, A, B

47
New cards

is a non-negative integer variable that can be accessed using only two special operations, P and V

Semaphore

48
New cards

is a segment of code that cannot be entered by a process while another process is executing a corresponding segment of the code.

Critical Section

49
New cards

is a named queue on which processes can wait for some condition to become true

Condition Variable

50
New cards
<p><span>Processes p and q execute the instructions x = x + 1 and x = x + 2, respectively.</span></p><p><span>Initially x = 0. After execution of the interleaved code, x = _____</span></p>

Processes p and q execute the instructions x = x + 1 and x = x + 2, respectively.

Initially x = 0. After execution of the interleaved code, x = _____

1

51
New cards

Which is Not True?

When a process is in the ready state, the CPU attained time is changing.

52
New cards

Two processes, p1 and p2, are executing using RR scheduling. The context switching time is S = 3.

Determine the maximum quantum size Q such that the gap between the end of a process p1's quantum and the start of p1's next quantum does not exceed

M = 28 time units.

What is quantum size? 22
Determine the percentage of CPU time wasted on context switching. 12%

53
New cards

Which is True?

With the rate monotonic algorithm, the shorter period process always has the higher priority.

54
New cards

Using the program shown below, identify the values of pid1 and pid at lines A, B, C, and D. Assume that the actual process id of the parent and child processes are 700 and 701, respectively. 

 

int main() {

pid_t  pid, pid1;

      pid = fork();

      if (pid < 0) {

                      fprintf(stderr, "Fork Failed");

                      return 1;

      } else if (pid > 0) {

               pid1= getpid();

               printf(“pid = %d\n”, pid);     /* A */

               printf(“pid1= %d\n”, pid1);  /* B */

               wait (NULL);

               return 0;

      } else {

               pid1= getpid();

               printf(“pid = %d\n”, pid);         /* C */

               printf(“pid1 = %d\n”, pid1);   /* D */

      }

}

 

A: 701  B:700  C:0  D:701

55
New cards

Which one is NOT contained in process control block (PCB)?

 

interrupt service ID

56
New cards

Transferring control of the CPU from one process to another

Context Switch

57
New cards

In Round Robin algorithm, ______ is a small amount of time during which a process is allowed to use the CPU

time quantum

58
New cards

________ perform critical operations that access I/O devices and the CPU's status and control registers

privileged instructions

59
New cards

The sum of the total CPU time and the waiting time is called _____

turnaround time

60
New cards

When CPU utilization is 80%, _____ scheduling is likely to produce a feasible schedule.

only EDF

61
New cards

Please list and briefly explain three Linux/Unix shell commands.

  1. pwd (Print Working Directory)
    This command displays the full path of the current directory you are working in. It helps you know your location in the filesystem hierarchy.
    ➤ Example: Typing pwd might return /home/student/projects.

  2. cd (Change Directory)
    Used to navigate between directories. You specify the name or path of the folder you want to enter.
    ➤ Example: cd Documents moves you into the "Documents" folder.

  3. nano
    A terminal-based text editor used to create or modify text files directly in the command line. It's simple and beginner-friendly.
    ➤ Example: nano notes.txt opens the file notes.txt for editing (or creates it if it doesn’t exist).

62
New cards

For time-sharing to work between applications, which technique should be used?

Interrupt

63
New cards

Which is NOT true?

 

Process state of PCB field maintains hardware registers and flags

64
New cards

Which one is Not True?

 

Multiple threads of the same process share CPU registers and stacks for code efficiency

65
New cards

This series of process state transitions is valid.

new -> ready -> run -> ready -> run -> blocked -> run -> terminated

False

66
New cards

In Realtime system, three periodic processes with the following characteristics are to be scheduled.

 

Process

Period

Total CPU time

p1

20

5

p2

100

15

p3

50

4

 

How many more processes, each with CPU time = 3 and period = 20, can run concurrently under EDF?

3

67
New cards

The sum of the individual fractions of CPU time used by each process is known as _____

CPU utilization

68
New cards

Multilevel feedback scheduling addresses the problems of starvation and fairness by using which technique?

 

Changing the priority of every process dynamically and using different time quantum values for priorities

69
New cards

server accepts and processes requests from clients. The server keeps the results of the most recent requests in memory as a cache.

  • A new request arrives on average every 20 ms.

  • The processing of each request takes 10 ms.

  • If the requested result is not in the memory cache, additional 65 ms are needed to access the disk.

  • On average, 80% of all requests can be serviced without disk access

  • The creation of a new thread takes 10 ms.

(1) Should the server be implemented as a single-threaded or a multi-threaded process? __Answer 1:__

(2) What percentage of requests would have to be satisfied without disk access for the single-threaded approach to be feasible? Please round to the first decimal point __Answer 2:___

  • Answer 1:multi-threaded

  • Answer 2: 84.6

70
New cards

A video streaming application is an example of a periodic process

True

71
New cards

The hardware/user gap is bridged by the OS or by other system software. Which of the following tasks would require OS support?

Input a character from the keyboard.

Definitely

72
New cards

The hardware/user gap is bridged by the OS or by other system software. Which of the following tasks would require OS support?

Invoke a high-level matrix manipulation operation.

Not necessarily

73
New cards

The hardware/user gap is bridged by the OS or by other system software. Which of the following tasks would require OS support?

Allocate n bytes of memory for a new data structure

Most likely

74
New cards

The hardware/user gap is bridged by the OS or by other system software. Which of the following tasks would require OS support?

Load a program into memory.

Definitely

75
New cards

The hardware/user gap is bridged by the OS or by other system software. Which of the following tasks would require OS support?


Change the layout of a document.

not necessarily

76
New cards

The hardware/user gap is bridged by the OS or by other system software. Which of the following tasks would require OS support?

Call a shared library function.

Most likely

77
New cards

The hardware/user gap is bridged by the OS or by other system software. Which of the following tasks would require OS support?


Call a function defined within the current program.

not necessarily

78
New cards

The hardware/user gap is bridged by the OS or by other system software. Which of the following tasks would require OS support?

Exit current program.

Definitely

79
New cards

The hardware/user gap is bridged by the OS or by other system software. Which of the following tasks would require OS support?

Sleep for n seconds.

Definitely

80
New cards
<p><span style="font-family: Roboto, sans-serif">Match the higher-level constructs to the corresponding low-level instruction sequences.</span></p><p></p><p><span style="font-family: Roboto, sans-serif">Copy f into a temporary file f'.</span><br><span style="font-family: Roboto, sans-serif">Wait until printer P not busy.</span><br><span style="font-family: Roboto, sans-serif">Reserve printer P.</span><br><span style="font-family: Roboto, sans-serif">Send file f' to printer P.</span><br><span style="font-family: Roboto, sans-serif">Release printer P.</span></p>

Match the higher-level constructs to the corresponding low-level instruction sequences.

Copy f into a temporary file f'.
Wait until printer P not busy.
Reserve printer P.
Send file f' to printer P.
Release printer P.

Send file to printer p

81
New cards
<p><span style="font-family: Roboto, sans-serif">Match the higher-level constructs to the corresponding low-level instruction sequences.</span></p><p><br><span style="font-family: Roboto, sans-serif">for all i:</span><br><span style="font-family: Roboto, sans-serif">&nbsp; &nbsp; for all j:</span><br><span style="font-family: Roboto, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; for all k:</span><br><span style="font-family: Roboto, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cij = Cij + Aik × Bkj</span></p>

Match the higher-level constructs to the corresponding low-level instruction sequences.


for all i:
    for all j:
        for all k:
            Cij = Cij + Aik × Bkj

C = A x b where

A,B,C are matrices

82
New cards
<p><span style="font-family: Roboto, sans-serif">Match the higher-level constructs to the corresponding low-level instruction sequences.</span></p><p></p><p><span style="font-family: Roboto, sans-serif">Given a file block i, determine the track number t and the block number j within t that correspond to block i.</span><br><span style="font-family: Roboto, sans-serif">Access block j on track t.</span></p>

Match the higher-level constructs to the corresponding low-level instruction sequences.

Given a file block i, determine the track number t and the block number j within t that correspond to block i.
Access block j on track t.

Access disk block i

83
New cards
<p><span style="font-family: Roboto, sans-serif">Match the higher-level constructs to the corresponding low-level instruction sequences.</span></p><p></p><p><span style="font-family: Roboto, sans-serif">If program p is too large to fit into memory, divide p into smaller partitions p1, p2, ...</span><br><span style="font-family: Roboto, sans-serif">Load p1 and start execution.</span><br><span style="font-family: Roboto, sans-serif">Whenever a different partition pi is needed, save current partition and load pi.</span><br><span style="font-family: Roboto, sans-serif">Resume execution.</span></p>

Match the higher-level constructs to the corresponding low-level instruction sequences.

If program p is too large to fit into memory, divide p into smaller partitions p1, p2, ...
Load p1 and start execution.
Whenever a different partition pi is needed, save current partition and load pi.
Resume execution.

Load program p into memory and execute p

84
New cards
<p><span style="font-family: Roboto, sans-serif">Match the higher-level constructs to the corresponding low-level instruction sequences.</span></p><p></p><p><span style="font-family: Roboto, sans-serif">Allocate new queue element e.</span><br><span style="font-family: Roboto, sans-serif">Copy x into e.</span><br><span style="font-family: Roboto, sans-serif">Insert e at rear of Q.</span></p>

Match the higher-level constructs to the corresponding low-level instruction sequences.

Allocate new queue element e.
Copy x into e.
Insert e at rear of Q.

Enqueue x into Q

85
New cards
<p><span style="font-family: Roboto, sans-serif">Multiprogramming generally improves CPU utilization and throughput.</span></p>

Multiprogramming generally improves CPU utilization and throughput.

True

86
New cards
<p><span style="font-family: Roboto, sans-serif">The main objective of time-sharing is to improve resource utilization.</span></p>

The main objective of time-sharing is to improve resource utilization.

False

87
New cards
<p><span style="font-family: Roboto, sans-serif">Multiprogramming and time-sharing are not used together.</span></p>

Multiprogramming and time-sharing are not used together.

False

88
New cards
<p><span style="font-family: Roboto, sans-serif">In a hypothetical system, the average computation spends 50% of total time using the CPU and the remaining 50% waiting for I/O.</span></p><p></p><p><span style="font-family: Roboto, sans-serif">To achieve best CPU utilization, _____ computations should run simultaneously.</span></p>

In a hypothetical system, the average computation spends 50% of total time using the CPU and the remaining 50% waiting for I/O.

To achieve best CPU utilization, _____ computations should run simultaneously.

more than 2

89
New cards
<p><span style="font-family: Roboto, sans-serif">In a hypothetical system, the average computation spends 50% of total time using the CPU and the remaining 50% waiting for I/O.</span></p><p></p><p><span style="font-family: Roboto, sans-serif">The use of time-sharing will _____.</span></p>

In a hypothetical system, the average computation spends 50% of total time using the CPU and the remaining 50% waiting for I/O.

The use of time-sharing will _____.

guarantee reasonable response to each computation

90
New cards
<p><span style="font-family: Roboto, sans-serif">Processes p1 and p2 share a single CPU and 2 independent I/O devices. Each process executes a compute-bound phase of 10 time units followed by an I/O-bound phase of 10 units.</span></p><p></p><p><br>Without multiprogramming, the total execution time of both processes is ____ time units.</p>

Processes p1 and p2 share a single CPU and 2 independent I/O devices. Each process executes a compute-bound phase of 10 time units followed by an I/O-bound phase of 10 units.


Without multiprogramming, the total execution time of both processes is ____ time units.

40

91
New cards
<p><span style="font-family: Roboto, sans-serif">Processes p1 and p2 share a single CPU and 2 independent I/O devices. Each process executes a compute-bound phase of 10 time units followed by an I/O-bound phase of 10 units.</span></p><p></p><p><br>With multiprogramming, the total execution time of both processes is ____ time units.</p>

Processes p1 and p2 share a single CPU and 2 independent I/O devices. Each process executes a compute-bound phase of 10 time units followed by an I/O-bound phase of 10 units.


With multiprogramming, the total execution time of both processes is ____ time units.

30

92
New cards
<p><span style="font-family: Roboto, sans-serif">Processes p1 and p2 share a single CPU and 2 independent I/O devices. Each process executes a compute-bound phase of 10 time units followed by an I/O-bound phase of 10 units.</span></p><p></p><p><br><span style="font-family: Roboto, sans-serif">If p1 and p2 use time sharing and the length of the time interval allocated to each process is negligible compared to the 10 time units of execution, then the total execution time of both processes is ____ time units.</span></p>

Processes p1 and p2 share a single CPU and 2 independent I/O devices. Each process executes a compute-bound phase of 10 time units followed by an I/O-bound phase of 10 units.


If p1 and p2 use time sharing and the length of the time interval allocated to each process is negligible compared to the 10 time units of execution, then the total execution time of both processes is ____ time units.

30

93
New cards
<p><span style="font-family: Roboto, sans-serif">Kernel functions may be invoked by _____.</span></p>

Kernel functions may be invoked by _____.

any program

94
New cards
<p><span style="font-family: Roboto, sans-serif">Privileged instructions may be executed by _____.</span></p>

Privileged instructions may be executed by _____.

only the kernel

95
New cards
<p><span style="font-family: Roboto, sans-serif">An application that needs to access an I/O device could not be written without _____.</span></p>

An application that needs to access an I/O device could not be written without _____.

kernel functions

96
New cards
<p>The kernel can execute _____ instructions.</p>

The kernel can execute _____ instructions.

both privileged and non-privileged

97
New cards
<p><span style="font-family: Roboto, sans-serif">The required number of right-clicks is _____.</span></p>

The required number of right-clicks is _____.

10

98
New cards
<p><span style="font-family: Roboto, sans-serif">The number of characters typed is _____.</span></p>

The number of characters typed is _____.

20

99
New cards
<p><span style="font-family: Roboto, sans-serif">he number of times Enter is pressed is _____.</span></p>

he number of times Enter is pressed is _____.

10

100
New cards
<p>Step 1</p>

Step 1

Open file f1 using an editor