Quizzes Flashcards
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