Os Lec Prelim Reviewer
Os Lec Prelim Reviewer
Os Lec Prelim Reviewer
• UNIX, Mach
• MS-DOS
• MS-Windows
• Windows/NT
• Chicago
• OS/2
• MacOS
• VMS
• MVS
• VM
Main-Memory Management
Memory is a large array of words or bytes, each with its own address. It is a repository of
quickly accessible data shared by the CPU and I/O devices.
Main memory is a volatile storage device. It loses its contents in the case of system
failure.
The operating system is responsible for the following activities in connections with
memory management:
• Keep track of which parts of memory are currently being used and by whom.
• Decide which processes to load when memory space becomes available.
• Allocate and de-allocate memory space as needed.
File Management
A file is a collection of related information defined by its creator. Commonly, files
represent programs (both source and object forms) and data.
The operating system is responsible for the following activities in connections with file
management:
• A buffer-caching system
• A general device-driver interface
• Drivers for specific hardware devices
Secondary-Storage Management
Since main memory (primary storage) is volatile and too small to accommodate all data
and programs permanently, the computer system must provide secondary storage to
back up main memory. Most modern computer systems use disks as the principle on-line
storage medium, for both programs and data.
The operating system is responsible for the following activities in connection with disk
management:
Protection System
Protection refers to a mechanism for controlling access by programs, processes, or users
to both system and user resources. The protection mechanism must:
Command-Interpreter System
Many commands are given to the operating system by control statements which deal
with:
Operating-System Structures
• System Components
• Operating System Services
• System Calls
• System Programs
• System Structure
• Virtual Machines
• System Design and Implementation
• System Generation
• Process Management
• Main Memory Management
• File Management
• I/O System Management
• Secondary Management
• Networking
• Protection System
• Command-Interpreter System
• This type of OS accepts more than one jobs and these jobs are batched/
grouped together according to their similar requirements. This is done by
computer operator. Whenever the computer becomes available, the batched
jobs are sent for execution and gradually the output is sent back to the user.
• It allowed only one program at a time.
• This OS is responsible for scheduling the jobs according to priority and the
resource required.
These systems use a concept of virtual memory for effective utilization of memory
space. Hence, in this OS, no jobs are discarded. Each one is executed using virtual
memory concept. It uses CPU scheduling, memory management, disc management and
security management.
Multiprocessor Operating Systems
Multiprocessor operating systems are also known as parallel OS or tightly coupled OS.
Such operating systems have more than one processor in close communication that
sharing the computer bus, the clock and sometimes memory and peripheral devices. It
executes multiple jobs at same time and makes the processing faster.
Multiprocessor systems have three main advantages:
The ability to continue providing service proportional to the level of surviving hardware
is called graceful degradation. Systems designed for graceful degradation are called fault
tolerant.
The multiprocessor operating systems are classified into two categories:
• Resources Sharing
• Computation speed up – load sharing
• Reliability
• Communications
• Requires networking infrastructure.
• Local area networks (LAN) or Wide area networks (WAN)
1. Resource allocation
2. Accounting
3. Protection
System Call:
• System calls provide an interface between the process and the operating
system.
• System calls allow user-level processes to request some services from the
operating system which process itself is not allowed to do.
• For example, for I/O a process involves a system call telling the operating
system to read or write particular area and this request is satisfied by the
operating system.
Virtual Machines
• A virtual machine takes the layered approach to its logical conclusion. It treats
hardware and the operating system kernel as though they were all hardware.
• A virtual machine provides an interface identical to the underlying bare
hardware.
• The operating system creates the illusion of multiple processes, each
executing on its own processor with its own (virtual) memory.
• The resources of the physical computer are shared to create the virtual
machines.
o CPU scheduling can create the appearance that users have their
own processor.
o Spooling and a file system can provide virtual card readers and
virtual line printers.
o A normal user time-sharing terminal serves as the virtual machine
operator’s console.
Advantages/Disadvantages of Virtual Machines
Interrupt Handling
• The operating system preserves the state of the CPU by storing registers and
the program counter.
• Determines which type of interrupt has occurred: polling, vectored interrupt
system
• Separate segments of code determine what action should be taken for each
type of interrupt
• Interrupt Time Line for a Single Process Doing Output
Direct Memory Access Structure
Storage Structure
Main memory – only large storage media that the CPU can access directly.
Secondary storage – extension of main memory that provides large nonvolatile storage
capacity.
Magnetic disks – rigid metal or glass platters covered with magnetic recording material
• Disk surface is logically divided into tracks, which are subdivided into sectors.
• The disk controller determines the logical interaction between the device and
the computer.
Storage Hierarchy
Storage systems organized in hierarchy.
• Speed
• Cost
• Volatility
Caching – copying information into faster storage system; main memory can be viewed
as a last cache for secondary storage.
Hardware Protection
• Dual-Mode Operation
• I/O Protection
• Memory Protection
• CPU Protection
Dual-Mode Operation
I/O Protection
Memory Protection
• Must provide memory protection at least for the interrupt vector and the
interrupt service routines.
• In order to have memory protection, add two registers that determine the
range of legal addresses a program may access:
o Base register – holds the smallest legal physical memory address.
o Limit register – contains the size of the range
• Memory outside the defined range is protected.
Hardware Protection
CPU Protection
Process State
As a process executes, it changes state
1. Both are same beast with different name or when this beast is sleeping (not
executing) it is called program and when it is executing becomes process.
2. Program is a static object whereas a process is a dynamic object.
3. A program resides in secondary storage whereas a process resides in main
memory.
4. The span time of a program is unlimited but the span time of a process is
limited.
5. A process is an 'active' entity whereas a program is a 'passive' entity.
6. A program is an algorithm expressed in programming language whereas a
process is expressed in assembly language or machine language.
Diagram of Process State
PROCESS CONTROL BLOCK, SCHEDULING QUEUES AND SCHEDULERS
Process Control Block (PCB)
Information associated with each process.
Process state: The state may be new, ready, running, waiting, halted, and SO on.
Program counter: The counter indicates the address of the next instruction to be
executed for this process.
CPU registers: The registers vary in number and type, depending on the computer
architecture. They include accumulators, index registers, stack pointers, and general-
purpose registers, plus any condition-code information. Along with the program counter,
this state information must be saved when an interrupt occurs, to allow the process to
be continued correctly afterward.
CPU-scheduling information: This information includes a process priority, pointers to
scheduling queues, and any other scheduling parameters.
Memory-management information: This information may include such information as the
value of the base and limit registers, the page tables, or the segment tables, depending
on the memory system used by the operating system.
Accounting information: This information includes the amount of CPU and real time used,
time limits, account numbers, job or process numbers, and so on.
Status information: The information includes the list of I/O devices allocated to this
process, a list of open files, and so on.
The PCB simply serves as the repository for any information that may vary from process
to process.
Process Scheduling Queues
Job Queue: This queue consists of all processes in the system; those processes are
entered to the system as new processes.
Ready Queue: This queue consists of the processes that are residing in main memory and
are ready and waiting to execute by CPU. This queue is generally stored as a linked list. A
ready-queue header contains pointers to the first and final PCBs in the list. Each PCB
includes a pointer field that points to the next PCB in the ready queue.
Representation of Process Scheduling
Schedulers
A scheduler is a decision maker that selects the processes from one scheduling queue to
another or allocates CPU for execution. The Operating System has three types of
scheduler:
• The long-term scheduler or job scheduler selects processes from discs and
loads them into main memory for execution. It executes much less frequently.
• It controls the degree of multiprogramming (i.e., the number of processes in
memory).
• Because of the longer interval between executions, the long-term scheduler
can afford to take more time to select a process for execution.
• The short-term scheduler or CPU scheduler selects a process from among the
processes that are ready to execute and allocates the CPU.
• The short-term scheduler must select a new process for the CPU frequently. A
process may execute for only a few milliseconds before waiting for an I/O
request.
Medium-term scheduler
The medium-term scheduler schedules the processes as intermediate level of scheduling
Processes can be described as either:
• I/O-bound process – spends more time doing I/O than computations, many
short CPU bursts.
• CPU-bound process – spends more time doing computations; few very long
CPU bursts.
Context Switch
• When CPU switches to another process, the system must save the state of the
old process and load the saved state for the new process.
• Context-switch time is overhead; the system does no useful work while
switching.
• Time dependent on hardware support
Deadlock is a situation where a set of processes are blocked because each process is
holding a resource and waiting for another resource acquired by some other process.
Consider an example when two trains are coming toward each other on same track and
there is only one track, none of the trains can move once they are in front of each other.
Similar situation occurs in operating systems when there are two or more processes hold
some resources and wait for resources held by other(s). For example, in the below diagram,
Process 1 is holding Resource 1 and waiting for resource 2 which is acquired by process
2, and process 2 is waiting for resource 1.
Memory management is the functionality of an operating system which handles or
manages primary memory and moves processes back and forth between main memory
and disk during execution. Memory management keeps track of each and every memory
location, regardless of either it is allocated to some process or it is free. It checks how
much memory is to be allocated to processes. It decides which process will get memory at
what time. It tracks whenever some memory gets freed or unallocated and
correspondingly it updates the status.
CPU SCHEDULING
1. System process
2. Interactive processes
3. Interactive editing processes
4. Batch processes
5. Student processes
Multi-Level Feedback Queue