Lecture Notes On Operating Systems
Lecture Notes On Operating Systems
Lecture Notes On Operating Systems
• In brief, an operating system is the set of programs that controls a computer. Some
examples of operating systems are UNIX, Mach, MS-DOS, MS- Windows,
Windows/NT, OS/2 and MacOS.
• An operating system is an important part of almost every computer system.
• A computer system can be divided roughly into four components: the hardware,
the operating system, the application programs and the users (Figure 1.1).
• System Components
• Process Management
• Main-Memory Management
Main-Memory is a large array of words or bytes. Each word or byte
has its own address. Main memory is a repository of quickly accessible data
shared by the CPU and I/O devices.
• File Management
A file is a collected of related information defined by its creator.
Computer can store files on the disk (secondary storage), which provide
long term storage.
• Secondary-Storage Management
• Networking
• Protection System
Protection refers to mechanism for controlling the access of programs,
processes, or users to the resources defined by a computer system.
• Program Execution
The system must be able to load a program into memory and to run
it. The program must be able to end its execution, either normally or
abnormally (indicating error).
• I/O Operations
A running program may require I/O. This I/O may involve a file or
an I/O device.
• File System Manipulation
The output of a program may need to be written into new files or
input taken from some files. The operating system provides this service.
• Error Detection
An error is one part of the system may cause malfunctioning of the
complete system. To avoid such a situation the operating system constantly
monitors the system for detecting the errors.
System Calls and System Programs
• System calls provide the interface between a process and the operating system.
These calls are generally available as assembly-language instructions, and are
usually listed in the manuals used by assembly-language programmers.
Lecture 3: Process Management
• The operating system is responsible for the following activities in connection with
process management: the creation and deletion of both user and system
processes; the scheduling of processes; and the provision of mechanisms for
synchronization, communication, and deadlock handling for processes.
Process state
process number
program counter
Registers
memory limits
.
.
• Basic Concepts
1. When a process switches from the running state to the waiting state (for.
example, I/O request, or invocation of wait for the termination of one of
the child processes).
2. When a process switches from the running state to the ready state (for
example, when an interrupt occurs).
3. When a process switches from the waiting state to the ready state (for
example, completion of I/O).
• Switching context.
• Switching to user mode.
• Jumping to the proper location in the user program to restart that program
• Scheduling Criteria
• Different CPU scheduling algorithms have different properties and may favor one
class of processes over another. In choosing which algorithm to use in a particular
situation, we must consider the properties of the various algorithms.
• Many criteria have been suggested for
comparing CPU scheduling algorithms.
2. Shortest-Job-First Scheduling
3. Priority Scheduling
4. Round-Robin Scheduling
P1 24
P2 3
P3 3
P1 P2 P3
0 24 27 30
Shortest-Job-First Scheduling
P1 6
P2 8
P3 7
P4 3
P4 P1 P3 P2
0 3 9 16 24
Priority Scheduling
P1 10 3
P2 1 1
P3 2 3
P4 1 4
P5 5 2
P2 P5 P1 P3 P4
Round-Robin Scheduling
P1 24
P2 3
P3 3