You are on page 1of 13

Question 1: Clarify the following terms in the context of Operating Systems:

֎ Process states
 Running: currently has the process
 Ready: could have CPU if available
 Block/waiting: waiting for some event
֎ Major operating systems functions
 Sharing data between users
 Sharing hardware between users
 Provide user interface
 Handling networking communication
 Recovery from errors
 Organizing data in secure way and rapid access
 Facilitating input/output
 Scheduling resources
 Preventing user interface
 Accounting for usage of resources
֎ PCB
 Process control block: data structure that keeps key elements about the process
within the system
 PCB contains process state, process ID, parent pointer, child pointer, CPU time
received, priority, pointer to memory allocated, pointer to allocated resources
֎ SVC
 Super visor call (SVC): Call to the operating systems to get services like allocate
more memory, communicate with other process, require initiation another process
֎ Interrupts
 Signals to the processor generated by hardware or software indicating an event that
needs attention
 Types of interrupts
• Synchronous: process currently in run state originated or initiated
• Asynchronous: otherwise
 Interrupt classes
• SVC(super visor call): call to the processor to get services
• Externa
• Machine change
• Program change
• Input/output
֎ Interrupts processing
 Operating system gains control
 Save registers (context save)
 Interrupt identification
 Decide the handler (interrupt service routine)
 The handler gains control
 After service restore register state (context load)
 Restart the operating system
֎ Kernel
 The basic part of operating system perform some tasks(frequent, quick)
 Small in size, intensively used
֎ Memory Interleaving
 Is a concept of dividing the main memory in a number of modules or banks
 Each module has its own memory address register and data register
 Technique for increasing memory speed
֎ Storage compaction
 Group the used memory slots at the one end of storage and the holes as a single
hole in the other end
 No waste afterward
 Every thing should stop for relocation
 Registration of relocation information for each process
 Consume system resources
֎ Relocation register
 Protect user processes from each other and from change the OS code and data
֎ Operating systems
 Is the program or firmware that control and manage computer resources
 Computer resources
• Hardware: CPU, memory, input/output devices
• Data: database
 Operating systems groups
• Batch
▪ Runs batch jobs, no online users or tasks
• Time Sharing
▪ Supports online tasks and online users
▪ Most of the OS you know is in this category
• Real Time(RTOS)
▪ Real time operating systems are used in computers that controls critical
systems such as: control machinery, scientific instruments
֎ Interrupt classes
 SVC(super visor call): call to the processor to get services
 External
 Machine change
 Program change
 Input/output
֎ Hole-coalescing
 Merge small holes into large hole
 Require registration of empty holes
֎ memory interleaving
 concept of dividing the main memory int number of modules or banks
 each module has its own memory address register and date register
 technique for increasing memory speed
֎ Pipelining
 Pipelining is the process of accumulating and executing computer instructions and
tasks from the processor via logical pipeline
 Simple 5 stages pipeline
• IF ➔ instruction fetch
• ID ➔ instruction decode
• EX ➔ execute
• MEM ➔ memory access
• WB ➔ write back

֎ Buffering
 A process reading data from modem
 Three types of buffering
• Unbuffered input
o Wake up the process when the buffer is full
• Buffering in kernel
o When kernel buffer is full page with user buffer is brought in and copy
at once
• Double buffering in kernel
֎ Memory management
 The memory needs two things for multiprogramming
• Relocation
• Protection
 The OS can not be certain where a program will be loaded in the memory
 Memory management goal is to minimize waste of memory
 The ideal world has memory
• Very large , Very fast
• Non-volatile
 Memory management strategies
• Fetch : when and which to bring to memory
• Placement : where to but in memory
• Replacement: which one move out for new comers
 Manage memory by using
• First fit
▪ Search the memory holes from the top of the memory and the first hole
that can fit use it
• Next fit
▪ Same as the first fit but keeps pointer at the place of the last allocation
and start the search from the position of the last allocation
• Best fit
▪ Search the empty holes for the closest in size to the current allocation.
The closest in size will be used for that allocation
• Worst fit
▪ Search for the largest hole that fits the required allocation
֎ memory Dynamic partitioning
 job Occupy as much as they need
 the program leaves holes the holes get smaller by time
֎ Thread
 Threads benefits
 Economy
 Resource sharing
 Responsiveness
 Segment of the process
 Two types (Single-threaded and Multi-threaded)
֎ Synchronized interrupts
 Process currently in run state originated or initiated
 Control unit issues interrupt after instruction has completed
֎ Asleep Process
 It is a computer program when you call this method, it sets the process to wait
until the specified amount of time proceeds and then goes and finds some process
to run
֎ Dispatcher
 Module gives control of the CPU to the processor selected by short term
scheduler, this involves:
• Switching context
• Switching to user mode
֎ DMA
 Direct Memory Access
 A special control unit may be provided to transfer a block of data between i/o
devices to main memory and from main memory to i/o devices without
continuous intervention by the processor
֎ Channel
 Disk controller, which control two disks has DMA capability, it provides two
DMA channels

Memory CPU

Channel 3
Channel 2

Control unit
֎ Bootstrap
 Is the program that initializes the operating system during startup
 Major function
 Bringing OS into memory and having the processor execute it
 Bringing RAM to know state
 Device Initialization
 Initialization of kernel data structure
 Agreement on interrupts and initialization
 Setting certain registers
 Setting the PIT (Programmable interval timer)
֎ Multiprogramming
 More than one program are executed at the same time
 This technique works for single-processing and multi-processing
֎ Multiprocessing
 Is used for system with more than one processor
 Can collectively run many tasks at the same time
֎ Multitasking
 Execution more than one task at the same time
 Most modern OS like Linux, Mac, Windows support multitasking
֎ User Thread
Created and maintained by the process kernel no nothing about them process take
time slots and decide which thread to execute
֎ Context Switching
 The system must be able to safely switch from one process to another
֎ Firmware
 Micro instructions stored on ROM/EPROM….
 Instruction cycle is fetch, decode, execute
 Micro instruction is decoded instructions normally executed with microcontroller but
also, possible execution with processors.
֎ Polling
 Is constantly checking status of a port to see if data is available. Processor
continually polls the port and when data is available, reads it
 Polled i/o is inherently inefficient
 Interrupt driven i/o is more efficient than polled i/o
 Interrupt driven i/o: i/o device interrupts the processor whenever it is ready.
Processor responds to hardware interrupt by executing an interrupt service routine
(ISR)
֎ Clocks
 Keeps date and time
 Normally kept with special battery to keep it running when computer powered off
 It coarse measure time but keeps real time
 Scheduling tasks to run at some specific time
֎ Timers
 Used to measure time precisely
 Used to trigger events every time interval
 Used to start tasks after some interval
֎ Fixed Partitioning
 Security easily maintained
 No overheads
 Poor utilization could happen
 Not complicated
 Better utilization
֎ Variable/Dynamic Partitioning
 Jobs occupy as much as they need
 No boundary observed
 Good utilization may happen
 Overheads are higher in security and placement
 The programs leaves holes the holes get smaller by time (badly fragmented memory)

֎ Scheduling
 Goal: which and when a process takes processor time
 Objectives
• Fair: the scheduler should treat all processes in fair criteria’s
• Throughput: the scheduler should try to maximize the number of process
executed per unit time
• Support active users: the active users have short jobs and require fast service.
so, scheduler should take in consideration jobs that belong to active users to
favor them
• Predictable: a process that is execute many times in the system should be
finished within about the same duration
• Overhead: schedulers take time to make the selection if that time is favor to be
as minimum as possible since that time is not paid by customers
• Maximize Resources utilization: computer resources utilization means
income and more services to customers which is desirable for the scheduler, the
schedulers should try to maximize the operation of resources
• No indefinite postponement: selection criteria of the scheduler should take in
consideration the process waiting time
• Support priorities: the schedulers should give the ability to mark process as
important over others
• Better service for best: a process that is behaving in a logic manner and
causing much of troubles to the OS should be favored over a process that do the
opposite
• Degradation gracefully: it is logic if the system load increases the system will
not performance will degrade but it should degrade with same ratio of the load
not die at some point of load
֎ Criteria’s
 I/O bound: the OS could learn from the behavior of the process if the process
perform many I/O’s compared to the use of the CPU, the OS mark that process as
I/O bound
 CPU bound: the process that uses a lot of CPU time compared to rate of I/O could
be marked by the OS as CPU bound
 Interactive/Batch: the OS could Know if the process is to support interactive user
waiting for response or it’s a batch process that is no one is waiting for immediate
response
 Priority: OS could support priorities which could be
• Static : priority is given by the user or taken from the user group and could not
be changed
• Dynamic : priority is set initially be the submit process and could be changed
• Purchased: is paid priorities that can not be altered by the OS if dynamic
 Page Faults: if virtual storage is implementation the number of times the process
request a page of the process that does not exist at real memory at the time of
request
 Preemption (preemptive ): the preemptive is the ability of the OS to take the
processor from a process by force. If the preemption is allowed the OS has the
control over the Quantum value. Quantum could be fixed or vary from process to
another
 Deadline
 Time to complete
֎ Virtual memory concepts
 Normally, associated with the ability to address storage space much greater than
that of real storage
 Disassociation: it is the key in implementing the virtual storage
 Mapping: is required to map virtual address to real addresses where real programs
run
 Dynamic address translation
• V ====> R
V(b, d) ====> r
• Takes virtual address and map it to real address
• If the request address is not exists in the real memory, it will initiate a process
to bring that block for the process and wake up that process afterward
 Virtual storage implementation schemes
• Pure paging
• Pure segmentation
• Combined paging/ segmentation
֎ Sharing in virtual memory
 More than one process page in map table could contain same real memory start
address
֎ Pure paging
 The virtual address space is divided into blocks of equal sizes(pages)
 The real address space is divided into blocks of equal sizes (page frames)
 Page frame can holed only one page
 Page map table contains
• Residency bits , Frame number, Virtual address as well as some sharing and
access controls bits
 Mapping by direct translation
• A methodology of mapping virtual address to real address if exists
 Associative storage
• Content addressable type of storage
• Used to store tables that has very high hit rate
• Fast, expensive, small in size
• Could be used to store page map table
 Mapping using pure associative storage
• The entire table is stored in the associative storage
 Mapping using combined tables and associative storage
• Only part of table is stored in the associative storage
 Sharing and security in paging system
• At least read only data and pure procedures could be shared by setting up the
page map tables of processes to point to same memory page fames
locations/number
 System faults
• Missing page fault, Page protection fault
֎ Page map table
 Page map table contains
• residency bits
• frame number
• virtual address as well as some sharing and access control bits
 associative could be used to store page map table
֎ Pure Segmentation
 segment is variable in size block
 virtual space divided into variable size blocks
 main memory divided into variable blocks
 segment map table contains residency bits, segment size, main storage start address,
secondary storage address, access bits
 table implementation (pure regular, pure associative, mixed associative with regular
 mapping system by dynamic address translation using segment map tables base
register and segment map table as well as the associative if exists
 sharing and security is implemented though the segment map table ,read only data
and pure procedures could be shared segments is done by making segment map
tables of different processed point to the same real memory segments
 system faults
• messing segment fault
• segment protection fault, segment overflow fault
֎ Combined virtual storage segmentation/paging scheme
(concept, dynamic address translation, tables, and SVC’s’)
 The virtual address space is divided into segments
 The segment is divided into integer number od pages
 Each segment is of size equal to multiple number of pages
 Each process has segment map table
 Each segment has page map table
 Dynamic address translation using segment map tables base register, segment map
table, segment map table as well as associative storage if applicable to perform the
translation
 Virtual address contains segment number, page number and offset
 Segment table entire contains other control bits, length, segment base
 Segment base is the physical address of the page table of that segment
 Page table entire contains P (present bit), M (modified bit), other control bits, frame
number
 SVC (supper visor call): call to the OS to get service

֎ Virtual memory management


 Memory management
• Fetch: when and which to bring to memory
• Placement: where to put in memory
• Replacement: which one move out for new comers
 Replacement strategies
• Principle of optimality: choose the block that will not be used for longest time
 Replacement implementation schemes
• Random (based on random generator)
• FIFO (first in first out)
• Least recently used
• Least frequently used
• Not used recently
• Second chance
֎ Dynamic address translation in paging
 By dynamic address translation using segment map tables base register and segment
map table as well as the associative if exists
֎ Memory Replacement (optimality condition-schemes)
 Replacement: which one move out for newcomers
 Optimality: choose the block that will not be used for longest time
 Schemes
• Random (based on random generator)
• FIFO (first in first out)
• Least recently used
• Least frequently used
• Not used recently
• Second chance
֎ Deadlock
 The process is waiting for a particular event that will never happen
 Necessary Conditions For Deadlocks ‘Coffman conditions’
• Mutual exclusion
• Hold and wait
• No preemption condition
• Circular wait condition
 Dealing with Deadlock
• Pretend no problem
• Deadlock prevention
• Deadlock avoidance
• Deadlock detection and recovery
֎ Starvation
 Process suffer from infinite postponement in the block state
֎ Deadlock prevention
 Denying Mutual Exclusion
• Spooling
 Denying wait for
• Request all resources needed before: Unit start
▪ Idle resources charges
▪ Indefinite postponements
 Denying no Preemption
• Processes requesting a resource if denied it must
▪ release the resources it has
▪ Indefinite Postponement
 Denying Circular Wait
• Resource numbering
֎ Deadlock Avoidance
 Bankers Algorithm
• Concern with management of resource of large number
• Requisition are studied to see if safe or not
• Safe allocations are grated otherwise postponed
• Safe allocations means there are at least one scenario exists to all processes
to complete
֎ Deadlock Detection and Recovery
 Detection
• Resource allocation Graph
▪ Graph reduction
▪ Detection algorithm
 Recovery
• Pick a process to remove
▪ Utilize the Suspend/Resume
▪ Check Point
֎ Pick to Kill criteria's
 Sharing many deadlocks
 Process that does not make any updates
 Process has least running time
֎ Race condition
 A shared variables may be subject to multiple reads for later update by more
than one asynchronous process.
 The net-update for the variables will be normally wrong.
 That is when more than one process in race to update for a shared variable that
may lead to wrong overall update.
 The solution to the problem is by enforcing mutual exclusion.
 Mutual Exclusion problem
• Preventing concurrent processes from doing “concurrent updates” to
shared variables.
• That is done by declaring the update of shared variables area of the
programs critical sections.
 Critical sections
• Mutual exclusive areas of the programs.
▪ Quick
▪ coded carefully
▪ No Blocking inside
֎ Mutual exclusion primitives
 To enforce mutual exclusion for a critical section: Use mutual exclusion
primitives.
 Mutual exclusion primitives
• Enter: Wait if others in More than on requesting and no one in select one
to go.
• Exit: Allow waiting to compete for going in.
֎ Semaphores
 Semaphore is a protected variable that can be altered with only by P,V, and
initialization of a semaphore.
 A semaphore variable is subject to S>=0 constrain
• P(S) is defined as
▪ If S>0
S=S-1
▪ Else
Wait on S.
• V(S) is defined as
▪ If Any one waiting on S
Pick on to Wakeup
▪ Else
S=S+1
֎ Disk Scheduling
 Magnetic Disk components:
• Spindle
▪ Rotates at speeds about 3600 rev/Min
▪ for spinning the platters
• Boom
▪ Moving arm assembly that includes the read/write head
▪ the read/write arm (for reading and writing data)
• Platters
▪ Magnetic media
▪ For storing data
• cylinder is comprised of the set of tracks described by all the heads (on
separate platters) at a single seek position
• A track is divided into segments of sectors
• A sector is the smallest physical storage unit on a disk, Each sector stores a
fixed amount of user-accessible data
 Read/Write operations
• Seek time : reaching the targeted track/cylinder
• Latency time : reaching the right sector
• Transmission : reading or writing the data
֎ Disk Scheduling Objectives
 Throughput : number of tasks read/wrote per unit time should be high
 Mean response time : average response time should be low
 Predictability : variance in task completion time should not be large
 Fair : All tasks should be treated almost equally
֎ Seek Optimization Techniques (Disk Scheduling)
 First Come First Serve
• First read /write task comes is the first task to be accomplished.
• The tasks may lead to large total seek time then overall delays.
 Shortest Seek Time First
• The next task is considered the task that requires least seek time from the
current position of the mesh.
 Scan
• Move From outer most requests to the inner most requests then from
inner to outer.
• Requests executed in the way of the scan as the head moves.
 C-Scan
• Unidirectional scan.
 N-step
• Like Scan but on requests available at the beginning of the sweep.
 Achenbach
• C-Scan but each Cylinder is served for exactly one track.
• Requests are arranged on the same track to optimize latency
• Requests overlapped are done on different sweeps.
֎ Performance Optimization Techniques
 Fragmentation’s and disk reorganization (DEFRAGE)
• files growth by time may lead to placement of a file on different tracks.
• The deletion of files may lead existence of fragments only for new files.
• So, at some point of time new files are placed on different tracks.
• That is: delay in the access time to that file.
• Disk should be reorganized.
 Compression
 Ram Disks
• is a representation of a hard disk using RAM resources, and it can take
the form of a hardware device or a virtual disk

You might also like