Quizzes Flashcards

1
Q

A virtual machine allows us to run multiple operating systems on a single computer. Select the best answer.

A

T- A virtual machine is a software that can run an operating system within it. Multiple virtual machines can run on a single physical machine.

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

In a Git version control system, local commits that are not pushed to the main code repository will be lost if the local machine crashes

A

T-Local commits are stored only on the local machine and not in the central code repository. If the local machine crashes, all your data is lost (unless you backed it up elsewhere)!

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

The static global variables that reside in the data segment of a process’s memory are generated at compile, not runtime. Select the best answer.

A

T-This is all known and declared at compile time and put in the data segment. On the flip side, malloc calls dynamically allocate memory at runtime in the heap.

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

Copy-on-write is a mechanism used to reduce the overhead of forking new processes. Select the best answer.

A

T-A child’s memory space is nearly identical to that of its parent. In a fork() operation, if we blindly create a child that is a replica of the parent, it is a lot of wasted work especially if the child address space is going to be overwritten later on through an exec() call. A lazy copy-on-write mechanism is used instead. If the child process modifies a piece of the memory, then a new copy of it is created.

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

The “Root” process, init, is created when the OS is booted. Select the best answer.

A

T-Init is the first process created, at the root of the process hierarchy.

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

After the exec() call, the child’s data segment is preserved and kept similar to that of its parent. Select the best answer.

A

F-After an exec() call, the child runs an entire new binary, and all its existing memory is reset. The new binary will not understand the old data segment if we don’t replace it.

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

Heap segment

A

All memory allocated via malloc() calls go into the heap, even if they are called within functions.

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

Which of the following statements is true if free(cArray) is left out?

A

cArray will be retained on the heap after the sum function call return-All malloc() allocated memory goes into the heap even if the malloc() calls are within functions. In this case, not freeing simply results in memory leaks but not segmentation faults. Since cArray is on the heap it will remain there even after the function call ends, if it is not explicitly deallocated.

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

Where is the local variable x stored in memory? Select the best answer.

A

Stack Segment-Any local variables in main are pushed into the stack if they are not declared as static variables.

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

Interrupts are only initiated by currently running processes.

A

F-Interrupts can be initiated by hardware, e.g. clock ticks, completion of I/O requests.

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

During a system call, a TRAP instruction occurs and executing the correct system call requires a jump to a specific address in OS address space, as indexed by the system call number.

A

T-Since a system call requires user mode to kernel mode transition, a TRAP has to occur. To avoid the TRAP jumping into any arbitrary location in the OS, it has to go through a dispatcher that figures out the right function call based on the system call number.

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

Blocked signals are lost permanently.

A

F-Blocked signals are buffered, and not lost.

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

When executing a TRAP instruction during a system call, the CPU mode bit changes from supervisor to user.

A

F- It goes from user to supervisor mode.

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

A regular function call requires fewer CPU cycles than a system call (assuming both have the same code).

A

T-A system call requires trapping to kernel, context switching and updating some data structures in the kernel. Hence it requires additional CPU cycles.

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

Which of the following is not an example signal that originates from a hardware interrupt?
Illegal memory access

SIGINT signal from one process to another

Clock pulse for updating system time

Input from keyboard, network, or disk

A

SIGINT signal from one process to another

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

When a process makes a system call, after the call completes, it may not get to run immediately.

A

T-The scheduler may pick another process to run instead of the process that made the call.

16
Q

During a system call, the system call number corresponding to the system call function is pushed onto the stack initially.

A

T-The stack is a convenient place for storing the system call number. This number will be popped off the stack when the kernel takes control, to figure out which system call to invoke.

17
Q

During a system call, the system call function caller’s current register values are first stored in the heap and then copied to the PCB.

A

F-The current register values are stored in the stack, not heap.

18
Q

Is the following statement true or false?

System calls are more expensive (i.e. require more instructions to run) than regular function calls.

A

T-System calls are more expensive because a context switch is required.

19
Q

A SIGKILL signal can be caught or ignored.

A

F-SIGKILL is a special signal that unconditionally kills a process, and is the last resort the OS uses to kill a process. Hence, the OS does not allow this signal to be caught or ignored by a process.

20
Q

One can overwrite a SIGINT default handler with a custom handler.

A

T-Correct. Unlike a SIGKILL, a SIGINT signal is a gentler way to terminate a process. The process is allowed to change its handling behavior.

21
Q

Is the following statement true or false?

Blocked signals are lost because the kernel drops these signals.

A

F-When signals of a given type are blocked, the kernel will buffer them for delivery when the signals are unblocked.

22
Q

Is the following statement true or false?

The more advanced sigaction() function provides the means to query for the most recent action associated with the signal, prior to any new actions being taken.

A

T-Based on the function signature of sigaction, the last parameter returns a reference to the current action associated with the signal prior to invoking its function.

23
Q

Consider a scenario where we have the following function that returns the round trip time to a server.

ping google.com

PING google.com (172.217.6.206): 56 data bytes

64 bytes from 172.217.6.206: icmp_seq=0 ttl=57 time=17.343 ms

64 bytes from 172.217.6.206: icmp_seq=1 ttl=57 time=17.436 ms

64 bytes from 172.217.6.206: icmp_seq=2 ttl=57 time=33.575 ms

Suppose we run the above program in the background, which of the following methods allows us to terminate the ping process right after starting this process? Select all that apply.
Press ctrl-C

Type in ‘kill %1’

Send a SIGKILL to the ping process based on its process ID

A

TYPE IN KILL%1- Pressing ctrl-C will not work since the process is running in the background.

24
Q

Consider the pipelined process

sleep 10 | sleep 15

What is the number of seconds for which the above process group will block? Enter your answer as a number in the space provided below. Do not enter any spaces or punctuation.

A

15-Since the two processes are running concurrently, it will block for the longer of two processes.

25
Q

Is the following statement true or false? Select the best answer.

Conditional variables and semaphores are functionally equivalent.

A

F-Correct.They are not functionally equivalent, e.g. semaphores maintain counters, while conditional variables are mostly used with monitors.

26
Q

Is the following statement true or false? Select the best answer.

TSL (Test-and-Set) is a software-based solution for mutual exclusion.

A

F-TSL is a hardware solution.

26
Q

Is the following statement true or false? Select the best answer.

A binary semaphore can only have a value of either 0 or 1.

A

T-A binary semaphore saturates at a value of 1 and is used as a mutex.

27
Q

Is the following statement true or false? Select the best answer.

The Test-and-Set (TSL) is superior to the Peterson’s solution because it does not result in busy waiting.

A

F-TSL also suffers from the busy wait problem.

28
Q

Is the following statement true or false? Select the best answer.

Two threads within the same process can write to the same memory.

A

T-Two threads in the same process share the same virtual memory and hence can write to the same memory.

29
Q

Is the following statement true or false? Select the best answer.

“Starvation freedom” means that if a thread/process wants to enter a critical section, it will eventually be granted permission to enter.

A

T-A thread/process is not “starved” if after asking to enter a critical section, it enters eventually. In contrast, a starved process/thread will not get a chance to enter (forever, or at least it has to wait a long time)

30
Q

Is the following statement true or false? Select the best answer.

In the context of semaphore implementations, “P” and “V” calls have to be atomic actions.

A

T- The P and V calls have to be atomic, if not, the increase and decrease of the counter value will cause problems.

31
Q

Is the following statement true or false? Select the best answer.

The Peterson’s solution does not require simple assignments and tests since the shared variables do not have to be atomic.

A

F- The whole basis of the Peterson’s solution is its reliance on certain atomic statements (simple assignments and tests). This means no context can happen for these statements.

32
Q

P1 has resource R1, and is requesting for R2 and R3.

P2 has resource R3, and is requesting for R4

P3 has resource R4, and is requesting for R1

P4 has resource R5 and is requesting for resource R6

P5 has resource R6 and is requesting for resource R3

For the situation listed above, which of the following processes that are involved in the deadlock? Select all that apply

A

p1,p2,p3

33
Q

P1 has resource R1, and is requesting for R2 and R3.

P2 has resource R3, and is requesting for R4

P3 has resource R4, and is requesting for R1

P4 has resource R5 and is requesting for resource R6

P5 has resource R6 and is requesting for resource R3

For the situation listed above, which of the following resources that are involved in the deadlock? Select all that apply

A

r4,r1,r3

34
Q

Which of the following solutions to the deadlock in the Dining Philosophers problem always allow close to half the philosophers to eat simultaneously? Select the best answer.

After taking the left fork, the program checks if the right fork is available. If not, put down left fork, wait for some time, and retry

Reverse the order of get chopstick[i] and get chopstick[i+1 mod N] for every other philosopher

Make get chopstick[i] and get chopstick[i+1 mod N] atomic by surrounding with a global binary (“mutex”) semaphore

Token ring. Each philosopher gets to eat once in a round robin fashion.

A

one of the middle two… explore

35
Q

Suppose that Alice and Bob are customers in a bank. Alice currently has a balance of $300 and Bob has a balance of $700. They make the following transactions: Alice transfers $200 to Bob and Bob transfers $600 to Alice, using two different processes that use the following code.

Process for Alice:
[a1] B = Balance (Bob)

[a2] A = Balance (Alice)

[a3] SetBalance(Bob, B + $200)

[a4] SetBalance(Alice, A - $200)

Process for Bob:
[b1] A = Balance (Alice)

[b2] B = Balance (Bob)

[b3] SetBalance(Alice, A + $600)

[b4] SetBalance(Bob, B - $600)

Note that [a1], …,[b4] are not part of the code but the index to reference each instruction when ordering them. For instance, one of the interleaved sequential orders of executing Process for Alice and Process for Bob can be

[a1], [a2], [a3], [b1], [b2], [b3], [a4], [b4]

If there is no mutual exclusion and all steps can be interleaved, what is the minimum amount that Alice can end up within her bank account after both processes are executed? You can assume that the balances of Alice and Bob are in shared memory and can be modified by either process.

A

100-The following instruction interleaving produces this balance for Alice: [a1], [a2], [b1], [b2], [a3] (Alice has $300 and Bob has $900), [b3] (Alice has $900 and Bob has $900), [b4] (Alice has $900 and Bob has $100), [a4] (Alice has $100 and B has $100). This happens because Alice and Bob pulled their own copies of A and B at the beginning and override the SetBalance() instructions from each other.