Skip to main content

OS

Hardware => Operating system => Application

 OS Provide
- Hardware Abstraction
- Resource management

Abstraction: B/W Application and hardware

- Easy program writing
- Reusable functionality
- Portable

Resource management
- Multiple app but limited resource
- Manage CPU, Memory, Network, Secondary Memory etc
  ---------------

CPU
Each have a unique address

- Memory addrs
- IO Addrs
- Memory Mapped IO addrs

Memory addrs
32 bit process
Range: 0- 2^32-1
 ----------------
Process
Stack
Heap
Data
Text

System call use to access resources of kernel mode
 ------------------

Sharing the CPU - Multi-programming and multi-tasking - Sharing in multi-processor environments * Race conditions and synchronization * Scheduling * Isolation of the OS and user programs * Security mechanisms * Access control * Security assessment

-------------------
CPU Vs RAM
- RAM hold data CPU compute on data

Memory Management
- Fragmentation: Under utilization
    -  Finding Right fit (First fit, Right fit)
- Deallocation: Merge smaller block when process free memory
Modern OS manage above using
- Virtual memory
- Segmentation
-----------
Virtual Memory (Memory Management technique)
- RAM split into fixed size partition called frames
- Page frames typically 4KBs

Split Process into equal block size
Block size = page frame size

Allocate block into page frame

Page table: to maintain map of page and block

- Need not to be contiguous
- Need to lookup page table to access memory

TLV Caches 
- Process block are on user space
- Page table are in kernel space

Demand paging:?
Page fault trap?

Replacement polices
- First in first out
- Last recently used
- least frequent useed

Swap in & swap out

Dirty Bit
Present BIT
 protection Bit

PAGE TABLE
block | Page frame | P | D  | protection Bit

MMU and Virtual memory mapping

---------------------------
Segmentation
Segment Descriptor table
------------------------
Process: program in execution


Process table
block | page frame

Kernel metadata

- Kernel stack
- user stack

PID: process unique id

process state
- new
- ready
- Block
- running

Queue of ready process

Process tree

init.d

Zombies: process terminated but PCB exist

Orphan: parent exit but child running
- Intentional
- daemons

 ELF executable
----------------------------
Event
- Interrupt
- Trap
- Exception

IDTR: Interrupt Descriptor table

CPU Context switching
Multitasking
 -------------------------------
CPU Scheduler
- FCFS (First come first serve)
     - The Convoy Effect
Simple
Fair: all job execute

Waiting time depend
short process stuck

2. SJF (Shortest job first)
- Min average waiting time
Not predictable
starvation

3. SRTF

4. Round robin
Data struct: FIFO (Queue)

Critical process:

Priority based scheduling
starvation

Multilevel queue
------------
Multiprocessor scheduling
 - Global queue
- Each cpu has own queue

Load balance
- Pull migration
- Push migration
------------------------------
Inter process communication
- Shared memory

Signal
- Async unidirectional

Synchronization

Race condition
- Critical section

Critical section
- Mutual exec
- Progress
- No starvation

Locks
Unlock

Critical section solution

Deadlock

Bakery Algorithm
Synchronization N > 2 process
Use to solve critical section problem

Hardware lock
spinlock

Mutexes
Thundering herd problem
priority inversion
priority inheritance

Semaphore
Producer-Consumer problem

             Buffer
P                              c

Dinning philosopher problem

Deadlock
Handle deadlock

Thread
Process can have multiple thread
Thread can have its own stack section, register
Light weight
Efficient communication b/w entities
Efficient context switching

pthread lib

User thread
Kernel thread

Thread pool

Comments

Popular posts from this blog

OFFSET in Computer Science

OFFSET in Computer Science In the post, We will understand what is the meaning of OFFSET in computer science with an example. In computer science offset comes picture at may place like packing a data structure, encoding the data etc in some standard protocol so that other parties can deserialise it and understand the data. We will understand its important how does it work with example. suppose we have a data structure for a student like { name:string[20] roll: int[4] course: string[25] batch: int[4] } We want to serialise below student data  { name:"Amit Gupta" roll: 1234 course:Computer Science" batch: 2018 } Our protocol follow the rule that we will insert a value and if space will remain empty we will fill it with $ for example length of "Amit Gupta" is 10 but standard size is 20 so will fill 10 $ after "Amit Gupta". So serialisation of above data will be Amit Gupta$$$$$$$$$$1234Computer Sc...

Variable In C

Variable Like any other programming language in C programming language, we use a variable to store value, a value is any data like a number a or a character. In this post, we will learn about datatype of C programming language. Type Of Variable In C In this section, we will discuss how to store the following type of variable in C How to store an integer in C? How to store a float in C? How to store a double in C? How to store a long in C? How to store a character in C? As we already discussed that variable used to store data so that we can use it of other computation, for example, suppose we want to calculate the sum of two number then we have to store these two numbers first only after that we can use these two stored value to compute the sum. The entity that used to store a value called variable. What does it mean is suppose we tell a variable to store a number whose value is 5, the variable will place this number 5 in memory and we can variable in...

Clique in Graph

Clique in Graph In this tutorial, we will learn about the clique in the graph theory. Clique In graph theory, a clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Supplementary angles

Supplementary angles Supplementary angles  are two angles with a sum of  180 ^\circ 1 8 0 ∘ 180, degree . A common case is when they lie on the same side of a straight line.