Quizzes Flashcards
(37 cards)
A virtual machine allows us to run multiple operating systems on a single computer. Select the best answer.
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.
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
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)!
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.
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.
Copy-on-write is a mechanism used to reduce the overhead of forking new processes. Select the best answer.
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.
The “Root” process, init, is created when the OS is booted. Select the best answer.
T-Init is the first process created, at the root of the process hierarchy.
After the exec() call, the child’s data segment is preserved and kept similar to that of its parent. Select the best answer.
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.
Heap segment
All memory allocated via malloc() calls go into the heap, even if they are called within functions.
Which of the following statements is true if free(cArray) is left out?
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.
Where is the local variable x stored in memory? Select the best answer.
Stack Segment-Any local variables in main are pushed into the stack if they are not declared as static variables.
Interrupts are only initiated by currently running processes.
F-Interrupts can be initiated by hardware, e.g. clock ticks, completion of I/O requests.
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.
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.
Blocked signals are lost permanently.
F-Blocked signals are buffered, and not lost.
When executing a TRAP instruction during a system call, the CPU mode bit changes from supervisor to user.
F- It goes from user to supervisor mode.
A regular function call requires fewer CPU cycles than a system call (assuming both have the same code).
T-A system call requires trapping to kernel, context switching and updating some data structures in the kernel. Hence it requires additional CPU cycles.
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
SIGINT signal from one process to another
When a process makes a system call, after the call completes, it may not get to run immediately.
T-The scheduler may pick another process to run instead of the process that made the call.
During a system call, the system call number corresponding to the system call function is pushed onto the stack initially.
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.
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.
F-The current register values are stored in the stack, not heap.
Is the following statement true or false?
System calls are more expensive (i.e. require more instructions to run) than regular function calls.
T-System calls are more expensive because a context switch is required.
A SIGKILL signal can be caught or ignored.
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.
One can overwrite a SIGINT default handler with a custom handler.
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.
Is the following statement true or false?
Blocked signals are lost because the kernel drops these signals.
F-When signals of a given type are blocked, the kernel will buffer them for delivery when the signals are unblocked.
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.
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.
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
TYPE IN KILL%1- Pressing ctrl-C will not work since the process is running in the background.