W2 - Processes (Part I) Flashcards
What does the compiler do with source code?
It turns source code into an executable containing instructions and data.
What does the OS load from an executable file into memory?
Instruction and data segments.
What two memory areas does the OS create for a running program?
The stack (for function calls) and the heap (for dynamic memory).
What happens after the OS loads the program into memory?
It transfers control to the program by setting the Program Counter (PC) and processor registers. (pc points to instructions segment in memory)
What two main responsibilities does the OS have while the program runs?
Provide services (like system calls)
Protect the OS and other programs
What happens in an OS without processes?
It can run only one program at a time.
Which operating system is an example of one without true processes?
MS-DOS on the IBM PC.
Why is having only one running program inconvenient?
You can’t multitask.
Why is having only one running program inefficient, when thinking about system resources?
The CPU becomes idle while waiting for I/O operations which are slower than CPU operations, and it wastes time.
With multiple processes, the OS can switch to another program and keep the CPU busy.
What type of I/O is the slowest?
Disk I/O.
What is throughput in the context of operating systems?
Maximizing the amount of calculation and useful work done by keeping the CPU busy.
Why do OSes need process abstraction?
Early OSes could only run one program at a time, making multitasking impossible and wasting CPU time waiting for slow I/O.
Process abstraction allows multiple programs to run at once, improving convenience and CPU efficiency by increasing throughput.
What is a process?
An instance of a running program with its own state and system resources.
What are some parts of a process’s current state?
Memory contents, program counter, stack and heap pointers, CPU registers.
What system resources can a process have?
Amount of memory, open files, devices in use, and more but not mentioned.
What information does the OS keep about processes?
Number of processes, process states (e.g., waiting), and resource usage (e.g., opened files).
Why does the OS need to keep track of process information?
To manage process execution, handle waiting and resources, protect processes, and clean up after termination.
What is included in a process’s memory?
Program code (read from file)
Data (global/static variables, heap, stack)
What is the process context?
The data the OS uses to manage a process, inc;luding the Process Control Block.
What is the Process Control Block?
A data structure used by the OS to store information about a process, including its state, program counter, CPU registers, memory info, and I/O status.
How does a process view its own execution?
A process runs to completion in sequence, unaware of any interruptions or other processes.
How does a user view program execution on a computer?
The computer appears to run multiple programs at once, creating the illusion of multitasking.
How does the CPU and OS manage multiple processes?
The CPU switches between processes, each of which is loaded into different memory locations (e.g., Process A at 5000, Process B at 8000, etc.). The dispatcher is responsible for managing these switches.
What are the different views of a process’s execution?
Process’s view: Runs sequentially to completion.
User’s view: Multiple programs run at once (multitasking illusion).
CPU & OS’s view: The OS switches between processes using a dispatcher, with each process loaded into separate memory locations.