Lecture 3: Processes and threads Flashcards
(42 cards)
What is the execution sequence?
- Fetch instruction at PC and save it in IR (instruction register)
- Decode instruction in IR
- Execute (possibly using registers)
- Write results to registers or memory
- Update PC
- Repeat
What does this mean:
lw r1, 100
Load the word from 100 into register r1.
What does this mean:
add r3, r1, r2
add r1 + r2 and save it in r3
What does this mean:
sw r3, 100
store the word that’s in r3 into address 100
What is a context (of execution)?
- The value of the registers (PC, stack pointer, heap pointer, etc.) - from the CPU
- What’s written in the memory (code, data, stack, heap)
- Internal data in the OS relevant to the program (user, priority, etc.)
When does the context change?
Every time there’s a change in the value of a register or the memory.
What is a process?
A process is a dynamic instance of an application execution
(an abstraction of “an individual computer”).
Moving between contexts is the process.
Resident process
A process that is currently executing on a CPU
Non-resident processes
Process that is not currently running in the CPU. The context is stored in a special location in memory.
When does a program become a process?
when the executable file is loaded into the memory (by the loader which is a component of the OS)
Every time you run a program it creates a new ____.
Every time you run a program it creates a new process.
A program can create ____ processes.
A program can create multiple processes.
Address space
The set of accessible addresses in the memory by the process (Given by two parameters: base and bound)
Who verifies that a process is accessing memory only in [base, base+bound]?
The CPU
When a process specifics address x, what does it actually mean?
base + x
This means that the same pointer address in different processes point to different memory.
Kernel memory
The OS’s address space
User memory
All the memory that isn’t the kernel’s memory (The OS’s address space)
When switching between processes, what needs to be saved?
The processes context (including everything in the CPU)
Everything in the memory does NOT need to be copied. (because no other process will be able to access it, because it is outside of the process’s address space)
PCB
Process control block:
A data structure that saves all the data the OS needs about a process.
What information is saved in a PCB?
- Process state (resident, reday, etc. and info for calculating the process’s priority)
- Process number
- Registers (including PC)
- Memory limits - base and bound
- List of open files
What are the states of the process? (Life-cycle)
- New - being created
- Running - being executed
- Waiting (=blocked) for some event (disk, terminal, timer)
- Preemption - going from running directly back to ready (without first waiting)
- Terminated
What is preemption and when does it occur?
Preemption is when a process is running and then gets kicked off but goes directly to the ready queue (no waiting).
Can only happen in time sharing and not multiprogramming.
What causes a process from being in a running state to a ready state?
An interrupt (for example sys call)
What causes a process from being in a ready state to a running state?
Scheduler dispatch