32-Bit vs 64-Bit OS
- A 32-bit OS
has 32-bit registers
, and it can access 2^32 unique memory addresses.- i.e.,
4GB
of physical memory.
- i.e.,
- A 64-bit OS
has 64-bit registers
, and it can access 2^64 unique memory addresses.- i.e.,
17,179,869,184 GB
of physical memory.
- i.e.,
- 32-bit CPU architecture can process 32 bits of data & information.
- 64-bit CPU architecture can process 64 bits of data & information.
Advantages of 64-bit over the 32-bit operating system
- Addressable Memory
- 32-bit CPU -> 2^32 memory addresses, 64-bit CPU -> 2^64 memory addresses
- RAM
- 32-bit OS can only use 4GB RAM
- However, upgrade that system with excess RAM to the 64-bit version of Windows, and you’ll notice a difference.
- Performance
- All calculations take place in the registers.
- When you’re performing math in your code, operands are loaded from memory into registers.
- So, having larger registers allow you to perform larger calculations at the same time.
- 32-bit processor can execute 4 bytes of data in 1 instruction cycle while 64-bit processor can execute 8 bytes of data in 1 instruction cycle.
- Compatibility
- 64-bit CPU can run both 32-bit and 64-bit OS. While 32-bit CPU can only run 32-bit OS.
- Better Graphics performance
- 8-bytes graphics calculations make graphics-intensive apps run faster.
Computer Storage
- Computer storage is of
two types
- Primary Memory
- Secondary Memory
- Internal Memory or Primary Memory
- This is
directly accessible
by the processor - Main Memory, Cache Memory & CPU registers.
- This is
- External Memory or Secondary Memory
- It is mainly used for the
permanent and long-term storage
of programs and data
- It is mainly used for the
- Register
Smallest unit of storage
. It is a part of CPU itself.- A register may hold an instruction, a storage address, or any data (such as bit sequence or individual characters).
- Registers are a type of computer memory used to quickly accept, store, and transfer data and instructions that are being used immediately by the CPU.
- Cache:
- Additional memory system that temporarily stores frequently used instructions and data for quicker processing by the CPU.
- Main Memory
- RAM
- Secondary Memory:
- Storage media, on which computer can store data & programs.
- Hard Disk, CD, DVD, Pen/Flash drive, SSD, etc
Comparison
- Cost:
Registers is most expensive, then comes cache, then main memory
- Secondary storages are cheaper than primary.
- Access Speed:
- Primary has higher access speed than secondary memory.
Registers has highest access speed, then comes cache, then main memory
- Volatility
- Primary memory is
volatile
- Secondary memory is
non-volatile
- Primary memory is
Introduction to Process
Program under execution
is called Process- When a program is loaded into the memory and it becomes a process, it can be divided into four sections ─
stack, heap text and data
- Stack
- Contains the temporary data such as method/function parameters, return address and local variables.
- If no Stack area available:
Stack overflow
- Heap
- This is dynamically allocated memory to a process during its run time
- If no heap area available:
Out of memory
orMemory insufficient
- Data
- Contains the
global and static variables
- Contains the
- Text/Code
- Code of the process
- The value of Program Counter and the contents of the processor’s registers.
How OS creates a process?
- Load the program & static data into memory.
- Allocate runtime stack.
- Heap memory allocation.
- IO tasks.
- OS handoffs control to main ().
Process Table
- All the process are being tracked by OS using a table like data-structure called
Process Table
- Each entry in the process table are called
Process Control Block
Process Control Block (PCB)
- A PCB is also an table like data-stracture which
contains information about the process
i.e. registers, quantum, priority, etc
Attributes of a process
- Process-id
- Process identification: Unique no given to a process
- Program Counter
- Contains the next instruction to be executed
- Process state
- Priority
- General purpose resisters
- Store the values of registers used
- List of open files and devices
- Protection
Process Life Cycle(Process States)
- When a process executes, it passes through different states.
- These stages may differ in different operating systems, and the names of these states are also not standardized
- Start/New
- This is the initial state when a process is first started/
created
- Jobs are
stored in Job Queue
- This is the initial state when a process is first started/
- Ready
- The process is waiting to be assigned to a processor
- Jobs are
sorted and stored in Ready Queue
- Running
- The processor executes its instructions
- Block or Wait
- Wating for a resource, during I/O or interupt
- And at this point jons are
stored in Waiting Queue
- Terminate/Completion
- After Execution is finished process goes to Terminated state
Process Queues
Job Queue
- In starting, all the processes get stored in the job queue.
- Processes are in
new/start state
- It is maintained in the
secondary memory
.
Ready Queue
- Ready queue is maintained in primary memory
- Processes in Ready state
Waiting Queue
- Processes in Wait state.
Schedular
- Job Schedular
- aka
Long term schedular
because its seheduling frequency is low, idle time is slightly high. - The Job scheduler picks some of the jobs and
put them in the primary memory
- Move processes from:
Job Queue(New state)--> Ready Queue(Ready State)
LTS controls degree of multi-programming
i.e the number of processes in the memory
- aka
- CPU Schedular
- aka
Short-term schedular
ordiapatcher
because its seheduling frequency is very, idle time is low. - The CPU Schedular picks the job from the
ready queue and dispatch to the CPU
for the execution. - Move processes from:
Ready Queue (Ready state)--> Running state
- aka
- Medium Term Scheduler
- Medium-term scheduling is a
part of swapping
. - It
removes the processes
from the memory. - It reduces the degree of multiprogramming.
- The medium-term scheduler is in-charge of
handling the swapped out-processes
- Medium-term scheduling is a
Orphan process
- The process whose parent process has been terminated and it is still running.
- Orphan processes are adopted by init process.
Init is the first process of OS
Zombie process / Defunct process
- A zombie process is a process whose
execution is completed but it still has an entry in the process table
- Zombie processes usually occur for child processes, as the parent process still needs to read its child’s exit status.
- Once this is done using the
wait system call
, the zombie process is eliminated from the process table. This isknown as reaping
- It is because parent process maycall wait () on child process for a longer time duration and child process got terminated much earlier.
- As entry in the process table can only be removed, after the parent process reads the exit status of child process.
- Hence, the child process remains a zombie till it is removed from the process table.
Swapping in Operating System
- Swapping is a
memory management scheme
- In which any process can be
temporarily swapped
from main memory to secondary memory - So that the main
memory can be made available
for other processes Types
- Swap-in
- Swap-out
Swap-out
is a method of removing a process from RAM and adding it to the hard disk.Swap-in
is a method of removing a program from a hard disk and putting it back into the main memory or RAM.- Swap-out and swap-in is
done by Medium Term Scheduler
Context-Switching
Switching the CPU to another process
requires performing a state save of the current process and a state restore of a different process.- When this occurs, the
kernel saves the context
of the old process in its PCB and loads the saved context of the new process scheduled to run. - It is
pure overhead
, because the system does no useful work while switching. - Speed varies from machine to machine, depending on the memory speed, the number of registers that must be copied etc.