Module 1 - Fundamental concepts Flashcards
What is the overall purpose of an operating system?
An operating system (OS) is system software that manages computer hardware and software resources and provides common services for computer programs. The OS controls the hardware and coordinates its use among the various application programs for the various user.
On a single (core) CPU, how can the operating system make several programs execute seemingly at the same time?
The objective of time sharing is user
interaction, to switch the CPU among jobs
so frequently that users can interact with
each program while they are running
seemingly at the same time.
What do we mean with operating system kernel?
The kernel is a computer program
that is the core of a computer’s
operating system, with complete
control over everything in the
system.
It is the part of the operating system that is running at all times. On boot, starts executing the first process such as init. It then waits for some event to occur.
What is the difference between a program, executable and process?
A program is a set of instructions which is in human readable format. A passive
entity stored on secondary storage.
An executable is a compiled form of a program including machine instructions and
static data that a computer can load and execute. A passive entity
stored on secondary storage.
A process ia an executable loaded into memory and executing or waiting. A process typically executes for only a short time before it either finishes or needs to perform I/O (waiting). A process is an active entity and needs resources such as CPU time, memory etc to execute.
What is the purpose of the stack?
To store temporary data such as function
parameters, local variables and return
addresses.
The stack grows from high addresses towards lower address.
Can processes share a single stack? Justify your answer
Processes do not share CPU stacks.
What are the names of the two modes?
User mode and Kernel mode.
What is the purpose of dual mode operation?
In order to protect the operating system from user processes.
How does dual mode achieve its purpose?
Dual mode operation place restrictions on the type and scope of operations that can be executed by the CPU.
Generally, when executing in kernel mode:
๏ All of the CPUs instructions are allowed.
๏ The kernel is allowed to access any memory address.
When executing in user mode:
๏ A subset of the CPUs instructions that would be dangerous for a user to execute are not allowed. For example instructions used to turn interrupts and exceptions on and off are not allowed.
๏ Only memory belonging to the process can be accessed.
This design allows the operating system kernel to execute with more privileges than user application processes.
In general, what does it mean for something to be synchronous or asynchronous?
Synchronous means happening, existing, or arising at precisely the same time.
Asynchronous simply means “not synchronous”.
In relation to the CPU, what does it mean for an event to be synchronous or asynchronous?
If an event occurs at the same instruction every time the program is executed with the same data and memory allocation, the event is synchronous. A synchronous event is directly related to the instruction currently being executed by the CPU.
On the other hand, an asynchronous event is not directly related to the instruction currently being executed by the CPU.
What is the purpose of exceptions and interrupts?
Interrupts and exceptions are used to
notify the CPU of events that needs
immediate attention during program
execution.
What are the differences between an exception and an interrupt?
Exceptions are internal and synchronous. They are used to handle internal program errors.
Overflow, division by zero and bad data address are examples of internal errors in a program.
Exceptions are produced by the CPU control unit while executing instructions and are considered to be synchronous because the control unit issues them only after terminating the execution of an instruction.
Interrupts are external and asynchronous. They are used to notify the CPU of external events.
Interrupts are generated by hardware devices outside the CPU at arbitrary times with respect to the CPU clock signals and are therefore considered to be asynchronous.
Examples:
Key-presses on a keyboard might happen at any time. Even if a program is run multiple times with the same input data, the timing of the key presses will most likely vary.
Read and write requests to disk is similar to key presses. The disk controller is external to the executing process and the timing of a disk operation might vary even if the same program is executed several times.
What is meant by CPU context?
At any point in time, the values of all
the registers in the CPU defines the
CPU context. Sometimes CPU state
is used instead of CPU context.
What steps are taken when handling an exception or interrupt?
‣ When an exception or interrupt occurs, execution transition from user mode to kernel mode.
‣ The cause of the interrupt or exception is determined.
‣ The exception or interrupt is handled.
‣ When the exception or interrupt has been handled execution resumes in user space.
But there is a problem. The exception/interrupt handler uses the same CPU (including the program counter and all other registers) as
the user processes.
When entering the exception/interrupt handler, values in all registers must be saved to memory before the kernel can use the registers.
–
Restoring cpu context:
–
Before resuming execution of a user process, the values of all registers must be restored using the values saved to memory earlier.