What is an OS’s task?
1) Abstraction: hide hardware details from applications/programmers/users
2) Resource Management: resources must be multiplexed in a fair way between applications/users
3) Protection: Different applications shouldn’t be able to disturb/manipulate each other
4) PROVIDING AN EXECUTION ENVIRONMENT FOR APPLICATIONS
Why is abstraction a central task of an OS
Why is protection still as important although most devices run an OS used by a single user only?
What is the advantage of fixed-size integer types like uint32_t?
The normal int types have different sizes depending on the OS. The fixed-size types help writing portable code; code that works on multiple different systems without modification
Explain all functions of * and & operators
User mode
-only non-privileged processor instructions can be executed
kernel mode
What are privileged instructions and give examples
Instructions that
- manipulate control registers for memory translation
- disable or enable interrupts
- access platform devices
+Load and store control registers
+Halt processor
+Write model-specific registers
+Read time-stamp counter
Basic data types in C
-char: 1B
-short: 2B
-int: 4B
-long long: 8B
-float: 4B
-double: 8B
Global variables
Local variables
What is a process?
A process is a program in execution - an instance of a program
Each process is associated with a OS data structure called process control block (PCB) that holds all state information
Concurrency vs parallelism
Concurrency: Multiple processes on the same CPU
Parallelism: Processes truly running at the same time with multiple CPUs
What is direct execution and its problems?
Direct execution: Allow user process to run directly on hardware, OS creates process and transfers control to starting point
Problems:
- Process can harm each other
- Could read/write other process data
- Process could run forever
- Process could do something small
80:20 rule
Programs can see more memory than available:
80% of process memory idle, 20% active working set
What are three kinds of data
Fixed-size data and code segments
Typical process address space layout
OS: Addresses where the kernel is mapped
Stack: Local Variables, function call parameters, return addresses
->
<-
Heap: Dynamically allocated data (malloc)
BSS: uninitialized data
Data: initialized data
RO-Data: Read-only data, strings
Text: Program, machine code
Processes vs threads
thread -> lightweight process
an execution stream that shares an address space
multiple threads within a single process
(multiple stacks within the same address space)
What are three occasions that invoke the kernel and switch to kernel mode?
-Syscalls: user mode process requires higher privileges
- interrupts: external device sends a signal to the CPU
- exceptions: CPU realizes a notable condition
types of syscalls
Trap instruction
The trap instruction switches the CPU to kernel mode and enters the kernel in the same predefined way for every syscall.
It is a procedure call that synchronously transfers the control
System Call Handler
What are possible events that cause processes to be created?