6. Interrupt and Exception Handling Flashcards
What is the most challenging part of implementing exec()?
Ensuring that, on failure, exec() can return to the calling process.
Specifically, we do not want to make any changes to the process’ address space until we are sure that things will succeed.
Solution: Prepare a separate address space and swap it in when everything is set appropriately.
Describe how a process dies.
Processes choose the moment of their own end by calling end() with an exit code.
What does wait() do?
The parent process calls wait() to retrieve the exit code of a specified child process.
What is a zombie thread/process?
A thread/process which has exited, but its parent process (or init) has not called wait() to retrieve its exit code yet. The mapping of PID to exit code occupies memory until wait() is called.
What happens if a process’s parent exits before it (the child) does?
The “orphaned” process is assigned the init process as a parent, which will collect its exit code when it exits. This is called reparenting.
How do we prevent zombies from taking over the machine?
A process’s parent receives the SIGCHILD signal when a child calls exit(), alerting it to the chance to retrieve the child’s exit status.
On some systems a process can choose to have its children automatically reaped by ignoring this signal.
On bash the relevant command is the appropriately-named disown. This allows children to continue running as daemons even after bash exits.
What is a blocking wait()?
Will block until the child exits, unless it has already exited, in which case it returns immediately
What is a non-blocking wait()?
Will not block. Instead, it returns status indicates if the child has exited and, if so, what the exit code was.
What is the difference between an errno and the return code of a syscall?
System calls have return code that matter in the kernel. The C library has wrappers that call the syscall and change the return codes to an errno that is meaningful in C.
What are the limitations or problems with the hardware resource that the operating system is trying to address?
There is only one (or at least, not that many) processor(s)
What are the mechanisms necessary to allow the processor to be shared?
Interrupts and context switching.
What do programmers achieve through processor multiplexing?
Concurrency (good) and synchronization (something that has to be done to safely multiplex).
How do we design good policies ensuring that processor sharing meets the needs of the user?
Processor scheduling.
Why does the operating system need special privileges (that user programs cannot have)?
In order to divide resources between processes the system needs a TRUSTED and privileged entity that can divide the resources and enforce the division. Remember that user programs can be buggy or malicious, so the rule is to never trust user processes to handle hardware multiplexing.
Why can’t processes share resources without a privileged arbiter?
Some processes are malicious (Steal memory from another process. Or do bad things with the system).
Some processes are buggy (Accessing memory from other processes accidentally because of bad code)