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

SIMPLE PYTHON HTTP SERVER

SIMPLE PYTHON HTTP SERVER In many use cases, we come across the situation where we need a simple server to test some command or test some applications. But creating a server programmatically is a time taking process. To solve the problem Python has created SimpleHTTPServer module. In this post, we will learn how to create a simple HTTP server in a single command on Ubuntu.  Create SimpleHTTPServe Using Commandline  python -m SimpleHTTPServer 8001 Above command will create a simple HTTP server for you at port 8001 Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Golang - Run & Compile

GOLANG RUN & COMPILE In the previous post, we have discussed how to install Go on Linux. In this post, We will discuss how to compile and run a Go program. Create folder HelloWorld mkdir HelloWorld cd HelloWorld Create file HelloWorld.go touch HelloWorld.go Copy below code into HelloWorld.go file package main import "fmt" func main() { fmt.Println("Hello, World") } Compile go build Run ./HelloWorld Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

BSNL Recruitment

BSNL Recruitment      Bharat Sanchar Nigam Limited (BSNL)  has released a notification for the post of   Management Trainees . Company Name BSNL Post Name    Management Trainees State India Salary Rs.  24,900-50,500 Number of Vacancy 300 Eligibility B.Tech Last Date 26-01-2019 Application Details Job Notification Apply Online Job Application BSNL Recruitment       Government Jobs in India Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. Rozgardesh ( रोजगार देश )

South East Central Railway: SECR

South East Central Railway: SECR Company Name         :  South East Central Railway: SECR Post Name                       :   Apprentice State                            :  Maharashtra Salary                           :  Number of Vacancy   :  313 Eligibility                     :  10th Pass  Last Date to Apply     :  15-09-2018 Application Details    :  Notification Apply Online              :  Apply Here Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.