OG DECK Flashcards
(178 cards)
What is an operating system?
An operating system is the software layer that manages a computer’s resources for its users and their applications.
What happens when you run a program?
CPU:- Fetches instructions stored in exe file- Loads data stored in exe file- Decodes and executes the instructions- Stores result to memory
What are the jobs of an OS?
- Allocates memory- Manages memory- Manages CPU- OS provides process abstraction- Manages devices- Basically manages hardware and provides process abstraction.- OS also allows you to communicate with the computer without knowing how to speak the computer’s language.
What are the design goals of an operating system?
- Convenience| - Efficiency of usage of CPU, memory etc.
Explain short: What is the goal of process abstraction?
The goal of process abstraction is to run multiple processes concurrently, by time sharing the cpu. We then need mechanisms (context switch) and policy(scheduler). This makes the illuision that each program has it’s own isolated machine.
What is virtualization of the CPU?
- It involves a single cpu acting as if it were multiple seperate CPUs- Enables users to run many concurrent programs
What can a program read and update when it is running?
- Memory (Data that the running program reads/writes is in memory)- Register (Because many instructions read/update the registers)
What is I/O?
I/O stands for input and output and is reffered to devices connected to a computer. This could be a mouse and keyboard.
Which states can a process be? Explain them| Give the possible transitions between the three states.
- Running: Process is running on a processor, executing instructions - Ready: process is ready to run , but Os has chosen not to run it at this given moment - Blocked: process har performed some operation that makes it not ready to run until some other event takes place. For example: when a process initiates an I/O request to disk or network, it becomes blocked and thus some other process can use the processor. Running to ready: OS preempts the running process.Running to Blocked: Process makes system call to innitiate IOReady to running: OS schedules process to run next.Blocked to ready: IO requested by process is done.- New- Dead
Which data structure is where the operating system keeps the program counter, stack pointer and other information about a process.
PCB (process control block)
What does a PCB (process control block) contains?
- Process identifier- Process state- Pointers to other related processes (parent)- CPU context of the process (saved when the process is suspended)- Pointers to memory location- Pointers to open files
What does API stand for?
Application programming interface (API)
Why do we have an API in the OS?
- The API contains sets of system calls, including create, wait and destroy.- System call is a function call into OS code that runs at a higher privilege level of the CPU- There are usually interfaces to get some status information about a process as well, such as how long it has run for, or what state it is in.-Makes it possible for all services in the operating system to communicate.
What does fork() do?
- Creates a new child process - All processes are created by forking from a parent - The init process is ancestor of all processes
What does exec() do?
In computing, exec() is a functionality of an operating system that runs an executable file in the context of an already existing process, replacing the previous executable.
What does exit() do?
Exit() terminates a process
What does wait() do?
Wait() causes a parent to block until child terminates/exits or a signal is received.
What happens during fork()?
- A new process is created by making a copy of parent´s memory image- The new process is added to the OS process list and scheduled- Parent and child start execution just after fork (with differnet return values)- Parent and child execute and modify the memory data independently
What happens during wait()?
- Terminated process exist as a zombie.- The parent process is then supposed to execute the wait() system call to read the dead process’s exit status and other information.- This allows the parent process to get information from the dead process. After wait() is called, the zombie process is completely removed from memory.- When a parent calls wait(), zombie child is cleaned up or “reaped”- Wait() block in parent until child terminates (non-blocking ways to invoke wait)- What id parent terminates before child? Init process adopts orphans and reaps them
What happends during exec()?
- A process can run exec() to load another executable to its memory image- So a child can run a different program from parent- Variants of exec() to pass commandline arguments to new executable
What different modes can an OS run a executable from?| Which two modes does the OS have?
User and kernel mode
What is kernel mode?
- It enables the OS to run system calls- Kernel does not trust user stack- Kernel does not trust user provided addressesIn Kernel mode, the executing code has complete and unrestricted access to the underlying hardware. It can execute any CPU instruction and reference any memory address. Kernel mode is generally reserved for the lowest-level, most trusted functions of the operating system. Crashes in kernel mode are catastrophic; they will halt the entire PC.
When is trap function called?
- System call (program needs OS service)- Program fault (program does something illegal, e.g. access memory it doesn´t have access to)- Interrupt as external devices needs attention of OS (e.g. network packet has arrived on network card)
What is a trap function?
It is a software interrupt generated by the user program or by an error when the operating system is needed by it to perform the system calls or an operation