0% found this document useful (0 votes)
24 views23 pages

Unit 1

Uploaded by

satya narayana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views23 pages

Unit 1

Uploaded by

satya narayana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

FUNDAMENTALS OF

OPERATING SYSTEMS

V.Sravanthi
Asst Prof, CSE
VRSEC
Course Outcomes
CO1 Understand the basic components of an Operating System K2 1.7.1

  Apply CPU Scheduling Algorithms to achieve K3 1.7.1, 2.6.3,


CO2 specific criteria 2.6.4, 2.8.3,
2.8.4, 3.6.3

  Apply the mechanisms used for process K4 1.7.1, 2.5.2,


CO3 synchronization, deadlock prevention and 2.6.3, 2.6.4,
deadlock detection 2.8.4, 3.7.1

K4 1.7.1, 2.5.2,
CO4
Apply different page replacement algorithms 2.6.3, 2.6.4,
2.8.4, 3.7.1

2
UNIT I
Introduction: What Operating Systems do
Operating-System Structures: Operating-System Services, User and Operating- System .Interface. System call-Types of Systems calls
Process- Process concepts, Process scheduling 
UNIT II
CPU Scheduling: Basic Concepts, Scheduling Criteria, Scheduling Algorithms: FCFS, SJFS,
Priority Scheduling, Round-Robin Scheduling.
Process Synchronization: Background, The Critical-Section Problem, Peterson’s Solution,
Semaphores-Semaphore Usage. 
UNIT III:
Deadlocks: System Model, Deadlock Characterization, Methods for Handling Deadlocks Deadlock Prevention, Deadlock Avoidance,
Deadlock Detection-Single Instance of Each Resource Type, Several Instance of Each Resource Type
Main Memory: Background, Contiguous Memory Allocation.
Paging: Basic Method
Swapping: Standard Swapping, Swapping with Paging.
UNIT IV:
Virtual Memory: Background, Demand Paging: Basic Concept, Copy-on-Write. Page Replacement: Basic Page Replacement, FIFO,
Optimal, LRU.
Secondary Storage Structure: Overview of Mass-Storage Structure, Disk Structure.
Disk Scheduling: FCFS, SCAN Scheduling Algorithms.
File-System Implementation: Directory Implementation, Allocation Methods, Free-Space Management

3
UNIT I

Introduction: What Operating Systems do

• What is an Operating System?


An operating system (OS) is a software that
acts as an interface between the hardware
and the applications. It manages computer
resources, including memory, processes,
and input/output operations. Without an
operating system, a computer would be
unable to function.
OPERATING SYSTEM SERVICES

An Operating System provides


services to both the users and
to the programs.
 It provides programs an
environment to execute.
 It provides users the services
to execute the programs in a
convenient manner.

6
Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC
Program execution

The system must be able to load a program into memory and to run that program. The
program must be able to end its execution, either normally or abnormally (indicating error).
O
S
I/O Operations
S
E A running program may require I/O, which may involve a file or an I/O device. For
R efficiency and protection, users usually cannot control I/O devices directly. Therefore, the
V operating system must provide a means to do I/O.
I
C File-System manipulation
E Programs need to read and write files and directories. They also need to create, delete,
S search and list file information. Many operating systems provide a variety of file systems,
sometimes to allow personal choice and sometimes to provide specific features or
performance characteristics. 7
Communications

O Communication may occur between processes that are executing on the same computer or
S between processes that are executing on different computer systems tied together by a
computer network.
S Communications may be implemented via shared memory, in which two or more processes
E
read and write to a shared section of memory, or message passing, in which packets of
R
information in predefined formats are moved between processes by the operating system.
V
I Error Detection
C
E The OS needs to be detecting and correcting errors constantly. Errors may occur in the CPU
S and memory hardware, in I/O devices and in the user program. For each type of error, the
operating system should take the appropriate action to ensure correct and consistent
computing. Sometimes, the OS has to halt the system or terminate an error-causing process or
return an error code.
Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC 8
Resource Allocation

O When there are multiple users or multiple jobs running at the same time, resources
S must be allocated to each of them.
The operating system manages many different types of resources. Some (such as CPU
S
E cycles, main memory, and file storage) may have special allocation code, whereas
R others (such as I/O devices) may have much more general request and release code.
V
I Accounting
C
A track is to be maintained of which users use how much and what kinds of
E
S computer resources. This record keeping may be used for accounting (so that users
can be billed) or simply for accumulating usage statistics. Usage statistics may be a
valuable tool for researchers who wish to reconfigure the system to improve
computing services.
Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC 9
Protection and
Security
O The owners of information stored in a multiuser or networked computer system may want to
S control use of that information.
When several separate processes execute concurrently, it should not be possible for one process
S
to interfere with the others or with the operating system itself.
E
R Protection involves ensuring that all access to system resources is controlled. Security of the
V system from outsiders is also important.
I Such security starts with requiring each user to authenticate themselves to the system, usually
C by means of a password, to gain access to system resources.
E
It extends to defending external I/O devices, including network adapters, from invalid access
S
attempts and to recording all such connections for detection of break-ins. If a system is to be
protected and secure, precautions must be instituted throughout it. A chain is only as strong as
its weakest link.
Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC 10
User Interface (UI)
Almost all operating systems have a user interface (UI), which can take several forms.
1. Command-line interface (CLI): Uses text commands and a method for entering them.
2. Batch interface: commands and directives to control those commands are entered into files,
and those files are executed.
3. Graphical user interface (GUI): It is a window system with a pointing device (like mouse) to
point to the I/O, choose from menus driven interface and to make choices viewing from a
number of lists and a keyboard to entry the texts.

Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC 11


SYSTEM CALLS
 In computing, a system call is the programmatic way in which a
computer program requests a service from the kernel of the
operating system it is executed on.
 This may include hardware-related services (for example, accessing
a hard disk drive), creation and execution of new processes, and
communication with integral kernel services such as process
scheduling.
 System calls provide an essential interface between a process and
the operating system.
 System calls provide an interface to the services made available by
an operating system. These calls are generally available as routines
written in C and C++, although certain low-level tasks may have to
be written using assembly-language instructions. 12
Example of how system calls are used

Writing a simple program to read data from one file and copy them to another file.

Example System Call Sequence source file


Acquire input file name
Write prompt to screen
Accept input
Acquire output file name
Even simple programs
Write prompt to screen may make heavy use of
Accept input the operating system.
Open the input file
if file doesn't exits, abort
Frequently, systems
Create out file execute thousands of
if file exits, abort system calls per second.
Loop
Read from input file
Write to output file
Until read fails
Close output file
Write completion message to screen
Terminate normally destination file

13
Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC
Types of System Calls
 System calls can be grouped roughly into six major categories:
process control, file manipulation, device manipulation,
information maintenance, communications, and protection.

14
Examples of Windows and Unix System Calls

15
Process Concept
Operating
Systems

V.SRAVANTHI
ASST PROF, CSE
Process Concept
An operating system executes a variety of programs:
– Batch system – jobs
– Time-shared systems – user programs or tasks
Many modern process concepts are still expressed in terms of jobs,
(e.g. job scheduling), and the two terms are often used
interchangeably.

Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC


The Process
 In computing, a process is an instance of a computer program that is being executed. It
contains the program code and its current activity.

 Process memory is divided into four sections:


 The text section comprises the compiled program code, read in from non-volatile storage
when the program is launched.
 The data section stores global and static variables, allocated and initialized prior to executing
main.
 The heap is used for dynamic memory allocation, and is managed via calls to new, delete,
malloc, free, etc.
 The stack is used for local variables. Space on the stack is reserved for local variables when
they are declared (at function entrance or elsewhere, depending on the language), and the space
is freed up when the variables go out of scope.
Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC
 A program is a passive entity, such as a file containing a list of instructions stored on disk
(often called an executable file).
 In contrast, a process is an active entity, with a program counter specifying the next
instruction to execute and a set of associated resources.
A program becomes a process when an executable file is loaded into memory.

 Although two processes may be associated with the same program, they are nevertheless
considered two separate execution sequences.

Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC


Process State
 When a process executes, it passes through different states.
 The state of a process is defined in part by the current activity of that process.
 These stages may differ in different operating systems, and the names of these states are
also not standardized.
A Process may be in one of the following states:
 NEW- The process is being created.
 READY- The process is waiting to be assigned to a processor.
 RUNNING- Instructions are being executed.
 WAITING- The process is waiting for some event to occur(such as an I/O completion or
reception of a signal).
 TERMINATED- The process has finished execution

Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC


► New - The process is in the stage of being created.
► Ready - The process has all the resources available that it needs to run, but the CPU is not currently
working on this process's instructions.
► Running - The CPU is working on this process's instructions.
► Waiting - The process cannot run at the moment, because it is waiting for some resource to become
available or for some event to occur.
► Terminated - The process has completed.
Process Control Block (PCB)
 Each process is represented in the operating system by a process control
block (PCB)—also called a task control block. It contains many pieces of
information associated with a specific process, including these:

► Process state: The state may be new, ready, running and so on


► Program counter: It indicates the address of the next instruction to be executed for this program.
► CPU registers: These vary in number and type based on architecture. They include accumulators,
stack pointers, general purpose registers etc. Along with
► CPU scheduling information: This includes process priority, pointers to scheduling queues and any
scheduling parameters.
► Memory-management information: This includes the value of base and limit registers (protection)
and page tables, segment tables depending on memory.
► Accounting information: It includes amount of CPU and real time used, account numbers, process
numbers etc
► I/O status information: It includes list of I/O devices allocated to this process, a list of open files etc
The architecture of a PCB is completely dependent on Operating
System and may contain different information in different operating
systems.

The PCB is maintained for a process throughout its lifetime, and is deleted once the process
terminates.
Operating Systems V.Sravanthi, Asst Prof, CSE, VRSEC

You might also like