Please enable JavaScript.
Coggle requires JavaScript to display documents.
Processes (Crux of the problem (How does even a single CPU device able to…
Processes
Crux of the problem
How does even a single CPU device able to pretend like it has infinite?
The OS mimics this behavior by quickly stopping one program and beginning another
Through quickly jumping around between programs, if done so fast enough, it looks like multiple programs are running
Downside is performance, it takes time to switch and a program would need to wait longer to finish compared to if it were run alone
How does the OS know which process to switch?
It follows a set of rules called policies
Intro
A process is a running program
The program itself is lifeless
It's just a bunch of instructions with maybe some data stored on the disk
Components
Address Space
The memory a process can address
Registers
Program Counter or Instruction Pointer
Stack Pointer
Frame Pointer :question:
List of All processes running
Tactics
Switch quickly between programs
Time Sharing
Gives allotted time access to an entire part of memory
Space sharing
A process gets it's own piece to keep of a part of memory
Process API
These are the tools the OS offers to a user that control processes
Create
Destroy
Wait
Resume
Status
Process Creation
How does a process start
A program is usually left on the disk in an executable form
Load up Stage
The OS needs to the contents of the program from wherever it is on memory
Eager vs Lazy loading
Early OS would load the entire program at once
More modern ones load as needed or lazily
Reserve some memory for run-time stack (stack)
Used for local variables,function parameters, and return addresses
Initialized with main's arguments argc(Arg count) and argv(Args list)
Reserve some memory for heap
Used for dynamically allocated data
Useful for data structures
I/O Maintanence
Information about Stdin,Stdout,Stderr,etc
Once everything is loaded last thing to be done is to jump the code to start at main
Summary
A process is a running program
The OS has to run many at the same time
It can even run multiple processes even if it has a single CPU
It does this by quickly and smartly jumping between processes
Jumping between tasks
Storing data
context
API
Commands
fork and exec interplay
wc myProgram.c > newfile.txt
A child process is Created first doing some intermediary work
In this case closing Std output and opening the file
Process States
Data Structures