You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
John von Neumann invented von Neumann computer architecture
CPU
Memory Unit
I/O devices (eg. SSD and disks)
Programs are stored on storage devices
Programs copied to memory for execution
CPU reads each
Fetch-execute algorithm
The program counter is loaded with address of first instruction, during boot sequence
The instruction register is loaded with the instruction from that address
Booting Sequence
Address of first instruction is fixed
Stored in Read Only Memory (ROM)
On i386 machines, ROM stores a Basic Input/Output system (BIOS)
This was replaced with the United Extended Firmware Interface (UEFI)
Needed for accessing storage greater than 2TB
Booting
Performs Power-On Self Test (POST)
Checks memory and device for their presence and correct operations
Old computers you can hear memory counting (noises from hard drive and CDROM).
The master boot record (MBR)
loaded from the boot device
stored at first logical sector on boot device
fits into single 4k byte disk sector (boot sector)
Describes physical layout of the disk
After getting info on boot device
BIOS loads a more sophisticated loader from other sectors on disk
Loader loads OS
OS Loaders
Old linux loader, LILO (Linux Loader)
Partly stored in MBR with the disk partition table
User can specify which disk partition and OS image to boot
After loading kernel image, LILO sets the kernel mode and jumps to entry point
Linux uses GRUB now (GRand Unified Bootloader)
Booting Sequence Brief
CPU Jumps to Fixed Address in ROM
Loads the BIOS (UEFI)
Performs POST
Loads the MBR (GPT) from boot device
Loads kernel image
Sets kernel mode
Linux Initialization
Trap table
Interrupt handlers
Scheduler
Clock
Kernel modules
Process manager
Process 1
Initialized from init (now systemmd for parallelism)
ancestor of all processes
Controls transitions between runlevels
Executes startup and shutdown scripts for each runlevel
Runlevels
shutdown
single-user
multi-user
full multi-user
X11
Process Creation
via fork system call family
System Calls
Allow us processes running at user mode to access kernel functions that run under kernel mode
Prevent processes from doing malicious operations
Halting system
Modifying MBR
Implemented through trap instructions
Parent Process
pid_tpid;
if((pid=fork()) ==0) {
while(1){
print("childs return value %d: I want to play.\n", pid);
}
} else {
while(1) {
print("parent's return value %d: After the project.\n", pid);
}
}
Child Process
pid_tpid;
if((pid=fork()) ==0) {
while(1){
print("childs return value %d: I want to play.\n", pid);
}
} else {
while(1) {
print("parent's return value %d: After the project.\n", pid);
}
}
Output
childs return value 0: I want to play.\n
childs return value 0: I want to play.\n
childs return value 0: I want to play.\n
...// context switch
parent's return value 3218: After the project.
parent's return value 3218: After the project.
parent's return value 3218: After the project.
...// context switch
childs return value 0: I want to play.\n
childs return value 0: I want to play.\n
childs return value 0: I want to play.\n
Why Clone a Process?
Simplifying parameter passing
Environment Variables, Permissions, etc
Performance optimization
Copy on write
A fork by itself is not very useful
To make a process run a program we use exec system call
exec starts a program by overwriting the current process
Thread Creation
use pthread_create() instead of using fork()
Newly created thread shares current process address space and resources