0% found this document useful (0 votes)
34 views67 pages

Unit 1

The document provides an overview of operating systems and their structure. It defines what an operating system is and describes its main functionalities like resource management and process scheduling. It also explains different types of operating systems and how they are structured, including simple, layered, and microkernel approaches.

Uploaded by

trw.dcn
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)
34 views67 pages

Unit 1

The document provides an overview of operating systems and their structure. It defines what an operating system is and describes its main functionalities like resource management and process scheduling. It also explains different types of operating systems and how they are structured, including simple, layered, and microkernel approaches.

Uploaded by

trw.dcn
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/ 67

UNIT 1: Overview of Os &

Processes
Introduction to OS

• Definition of OS

• Functionalities of OS
What is an Operating System?

• A program that acts as an intermediary between a user


of a computer and the computer hardware
• Operating system goals:
• Execute user programs and make solving user problems
easier
• Make the computer system convenient to use
• Use the computer hardware in an efficient manner
Computer System Structure

• Computer system can be divided into four components:


• Hardware – provides basic computing resources
• CPU, memory, I/O devices
• Operating system
• Controls and coordinates use of hardware among various
applications and users
• Application programs – define the ways in which the system
resources are used to solve the computing problems of the users
• Word processors, compilers, web browsers, database systems,
video games
• Users
• People, machines, other computers
Four Components of a Computer System
Operating System Functionalities
• OS is a resource allocator
• Manages all resources
• Decides between conflicting requests for efficient and fair resource
use
• OS in a Process Management
• This can be done through scheduling
• OS in a Memory Management
• OS in a I/O Device Management
• OS is a control program
• Controls execution of programs to prevent errors and improper use
of the computer
Operating System Definition (Cont.)

• “The one program running at all times on the


computer” is the kernel.
• The kernel is the core component of the operating
system.
• It is a piece of software that resides in the
privileged mode of the computer's central
processing unit (CPU) and has direct access to the
hardware.
Operating System Structure

• Multiprogramming (Batch system) needed for efficiency


• Single user cannot keep CPU and I/O devices busy at all times
• Multiprogramming organizes jobs (code and data) so CPU always has one to execute
• A subset of total jobs in system is kept in memory
• One job selected and run via job scheduling
• When it has to wait (for I/O for example), OS switches to another job

• Timesharing (multitasking) is logical extension in which CPU switches jobs so


frequently that users can interact with each job while it is running, creating interactive
computing
• Response time should be < 1 second
• Each user has at least one program executing in memory process
• If several jobs ready to run at the same time  CPU scheduling
• If processes don’t fit in memory, swapping moves them in and out to run
• Virtual memory allows execution of processes not completely in memory
Operating-System Operations (cont.)

• Dual-mode operation allows OS to protect itself and


other system components
• User mode and kernel mode
• Mode bit provided by hardware
• Provides ability to distinguish when system is running user code
or kernel code
• Some instructions designated as privileged, only executable in
kernel mode
• System call changes mode to kernel, return from call resets it to
user
• Increasingly CPUs support multi-mode operations
• i.e. virtual machine manager (VMM) mode for guest VMs
Transition from User to Kernel Mode
• Timer to prevent infinite loop / process hogging resources
• Timer is set to interrupt the computer after some time period
• Keep a counter that is decremented by the physical clock.
• Operating system set the counter (privileged instruction)
• When counter zero generate an interrupt
• Set up before scheduling process to regain control or terminate
program that exceeds allotted time
Types of OS
1. Batch Operating System:
• Characteristics:
• Jobs are submitted in advance, and the operating system
processes them sequentially.
• Limited interactivity; users do not interact with the system
during job execution.
• Efficiency is gained through the automatic execution of
jobs without manual intervention.
• Example: Early mainframe systems like IBM OS/360.
In these systems, users would submit their batch jobs,
and the system would process them in the order they
were received.
Multiprogramming Operating System:
1. Characteristics:
1. Allows multiple programs to be loaded into the memory
simultaneously.
2. The operating system selects a program for execution, and
when one program is waiting (e.g., for I/O), it switches to
another program.
3. Improves CPU utilization and overall system throughput.
2. Example: UNIX and Windows. These operating systems
efficiently handle multiple processes running concurrently,
improving the overall efficiency of the system.
Multitasking Operating System:
1.Characteristics:
1. Extends the idea of multiprogramming by allowing
multiple tasks to run concurrently.
2. The operating system divides the CPU time among
multiple tasks, giving the illusion of simultaneous
execution.
3. Provides a more responsive and interactive computing
experience.
2.Example: Modern desktop operating systems like Windows,
macOS, and Linux. Users can run multiple applications
simultaneously, such as browsing the web, listening to music, and
working on documents.
Multiprocessing Operating System:
1.Characteristics:
1. Supports the execution of processes on multiple processors
or cores simultaneously.
2. Enhances system performance and throughput by
parallelizing task execution.
2.Example: Linux, Unix variants, and some versions of Windows.
These operating systems are designed to take advantage of
multiple processors, improving overall system performance.
Real-Time Operating System (RTOS):
System that control scientific experiments, medical imaging
system, industrial control systems are real-time systems.
1.Characteristics:
1. Designed for applications with strict timing and
responsiveness requirements.
2. Ensures that tasks are performed within specified deadlines.
3. Common in embedded systems, control systems, and critical
applications.
2.Example: VxWorks, FreeRTOS, and QNX. These operating
systems are used in scenarios where timely and predictable task
execution is crucial, such as in aviation or medical devices.
1.Distributed Operating System:
1.Characteristics:
1. Runs on multiple machines and allows them to work
together as a single system.
2. Provides the illusion of a single operating system
spanning multiple devices.
3. Facilitates resource sharing and load balancing.
2.Example: Google's Chrome OS, Amoeba, and Plan 9 from Bell
Labs. These operating systems distribute tasks across a network
of machines for improved scalability and reliability.
1.Network Operating System:
• A network operating system (NOS) is designed to
enable multiple computers to communicate, share
resources, and access common services within a
network.
• It serves as the intermediary between the hardware
and application software, ensuring efficient and
secure data exchange in a networked environment.
• Examples of network operating systems include
Novell NetWare, Microsoft Windows Server, and Linux-
based systems like Ubuntu Server.
Operating System Structure
• General-purpose OS is very large program and its
complex to design
• Various ways to structure ones
• Simple structure – MS-DOS
• More complex -- UNIX
• Layered – an abstrcation
• Microkernel -Mach
Simple Structure -- MS-DOS
• MS-DOS – written to
provide the most
functionality in the least
space
• Not divided into modules
• Although MS-DOS has some
structure, its interfaces and
levels of functionality are not
well separated
Non Simple Structure -- UNIX
UNIX – limited by hardware functionality, the
original UNIX operating system had limited
structuring. The UNIX OS consists of two separable
parts
• Systems programs
• The kernel
• Consists of everything below the system-call interface and
above the physical hardware
• Provides the file system, CPU scheduling, memory
management, and other operating-system functions; a large
number of functions for one level
Traditional UNIX System Structure
Beyond simple but not fully layered
Layered Approach
• The operating system is
divided into a number of
layers (levels), each built
on top of lower layers.
The bottom layer (layer
0), is the hardware; the
highest (layer N) is the
user interface.
• With modularity, layers
are selected such that each
uses functions
(operations) and services
of only lower-level layers
Microkernel System Structure
• Moves as much from the kernel into user space
• Mach example of microkernel
• Mac OS X kernel (Darwin) partly based on Mach
• Communication takes place between user modules
using message passing
• Benefits:
• Easier to extend a microkernel
• Easier to port the operating system to new architectures
• More reliable (less code is running in kernel mode)
• More secure
• Detriments:
• Performance overhead of user space to kernel space
communication
Microkernel System Structure
Modules
• Many modern operating systems implement
loadable kernel modules
• Uses object-oriented approach
• Each core component is separate
• Each talks to the others over known interfaces
• Each is loadable as needed within the kernel
• Overall, similar to layers but with more flexible
• Linux, Solaris, etc
Solaris Modular Approach
Hybrid Systems
• Most modern operating systems are actually not one
pure model
• Hybrid combines multiple approaches to address
performance, security, usability needs
• Linux and Solaris kernels in kernel address space, so
monolithic, plus modular for dynamic loading of
functionality
• Windows mostly monolithic, plus microkernel for different
subsystem personalities
• Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa
programming environment
• Below is kernel consisting of Mach microkernel and BSD
Unix parts, plus I/O kit and dynamically loadable modules
(called kernel extensions)
Mac OS X Structure
Operating System Components
Process Management

The process management component is a procedure for managing many


processes running simultaneously on the operating system. Every running
software application program has one or more processes associated with them.

For example, when you use a search engine like Chrome, there is a process
running for that browser program.

Process management keeps processes running efficiently. It also uses memory


allocated to them and shutting them down when needed.

The execution of a process must be sequential so, at least one instruction


should be executed on behalf of the process.
Functions of process management

 Process creation and deletion.


 Suspension and resumption.
 Synchronization process
 Communication process
File management
A file is a set of related information defined by
its creator. It commonly represents programs
(both source and object forms) and data. Data
files can be alphabetic, numeric, or
alphanumeric.
Function of file management
•File and directory creation and deletion.
•For manipulating files and directories.
•Mapping files onto secondary storage.
•Backup files on stable storage media.
Network Management

Network management is the process of administering and managing


computer networks. It includes performance management, provisioning
of networks, fault analysis, and maintaining the quality of service.

A distributed system is a collection of computers or processors that


never share their memory and clock. In this type of system, all the
processors have their local memory, and the processors communicate
with each other using different communication cables, such as fibre
optics or telephone lines.

The computers in the network are connected through a communication


network, which can configure in many different ways. The network can
fully or partially connect in network management, which helps users
design routing and connection strategies that overcome connection and
security issues.
Main Memory management
Main memory is a large array of storage or bytes, which has an address. The
memory management process is conducted by using a sequence of reads or
writes of specific memory addresses.
It should be mapped to absolute addresses and loaded inside the memory to
execute a program. The selection of a memory management method depends on
several factors.

Main memory offers fast storage that can be accessed directly by the CPU. It is
costly and hence has a lower storage capacity. However, for a program to be
executed, it must be in the main memory.
Main Memory management
I/O Device Management
One of the important use of an operating system that helps to
hide the variations of specific hardware devices from the user.
Functions of I/O management

The I/O management system offers the following


functions, such as:
•It offers a buffer caching system
•It provides general device driver code
•It provides drivers for particular hardware devices.
•I/O helps you to know the individualities of a
specific device.
Security Management

The various processes in an operating system need to be secured from other


activities. Therefore, various mechanisms can ensure those processes that want to
operate files, memory CPU, and other hardware resources should have proper
authorization from the operating system.
Security refers to a mechanism for controlling the access of programs, processes, or
users to the resources defined by computer controls to be imposed, together with
some means of enforcement.

For example, memory addressing hardware helps to confirm that a process can be
executed within its own address space. The time ensures that no process has control
of the CPU without renouncing it. Lastly, no process is allowed to do its own I/O to
protect, which helps you to keep the integrity of the various peripheral devices.
Command Interpreter System

One of the most important components of an operating system is its command


interpreter. The command interpreter is the primary interface between the user and
the rest of the system.
Many commands are given to the operating system by control statements. A
program that reads and interprets control statements is automatically executed
when a new job is started in a batch system or a user logs in to a time-shared
system. This program is variously called.

•The control card interpreter,


•The command-line interpreter,
•The shell (in UNIX), and so on.

Its function is quite simple, get the next command statement, and execute it. The
command statements deal with process management, I/O handling, secondary
storage management, main memory management, file system access, protection,
and networking.
A View of Operating System Services
Operating System Services
• Operating systems provide an environment for execution of programs and
services to programs and users
• One set of operating-system services provides functions that are helpful to the
user:
• User interface - Almost all operating systems have a user interface (UI).
• Varies between Command-Line (CLI), Graphics User Interface
(GUI), Batch
• Program execution - The system must be able to load a program into
memory and to run that program, end execution, either normally or
abnormally (indicating error)
• I/O operations - A running program may require I/O, which may
involve a file or an I/O device
Operating System Services (Cont.)
• One set of operating-system services provides functions that are helpful to the user
(Cont.):
• File-system manipulation - The file system is of particular interest. Programs
need to read and write files and directories, create and delete them, search them,
list file Information, permission management.
• Communications – Processes may exchange information, on the same computer
or between computers over a network
• Communications may be via shared memory or through message passing
(packets moved by the OS)
• Error detection – OS needs to be constantly aware of possible errors
• May occur in the CPU and memory hardware, in I/O devices, in user
program
• For each type of error, OS should take the appropriate action to ensure
correct and consistent computing
• Debugging facilities can greatly enhance the user’s and programmer’s
abilities to efficiently use the system
Operating System Services (Cont.)
• Another set of OS functions exists for ensuring the efficient operation of the system
itself via resource sharing
• Resource allocation - When multiple users or multiple jobs running
concurrently, resources must be allocated to each of them
• Many types of resources - CPU cycles, main memory, file storage, I/O
devices.
• Accounting - To keep track of which users use how much and what kinds of
computer resources
• Protection and security - The owners of information stored in a multiuser or
networked computer system may want to control use of that information,
concurrent processes should not interfere with each other
• Protection involves ensuring that all access to system resources is
controlled
• Security of the system from outsiders requires user authentication,
extends to defending external I/O devices from invalid access attempts
System Programs
• System programs(System Utilities) provide a
convenient environment for program development and
execution. They can be divided into:
• File management
• Status information
• File modification
• Programming language support
• Program loading and execution
• Communications
• Background services
• Application programs
• Most users’ view of the operation system is defined by
system programs, not the actual system calls
System Programs
• Provide a convenient environment for program
development and execution
• Some of them are simply user interfaces to system calls; others
are considerably more complex

• File management - Create, delete, copy, rename, print,


dump, list, and generally manipulate files and
directories

• Status information
• Some ask the system for info - date, time, amount of available
memory, disk space, number of users
• Others provide detailed performance, logging, and debugging
information
• Typically, these programs format and print the output to the
terminal or other output devices
• Some systems implement a registry - used to store and
System Programs (Cont.)
• File modification
• Text editors to create and modify files
• Special commands to search contents of files or perform
transformations of the text
• Programming-language support - Compilers, assemblers,
debuggers and interpreters sometimes provided
• Program loading and execution- Absolute loaders, relocatable
loaders, linkage editors, and overlay-loaders, debugging systems
for higher-level and machine language
• Communications - Provide the mechanism for creating virtual
connections among processes, users, and computer systems
• Allow users to send messages to one another’s screens,
browse web pages, send electronic-mail messages, log in
remotely, transfer files from one machine to another
System Programs (Cont.)
• Background Services
• Launching System Programs at boot time
• Some for system startup, then terminate
• Some from system boot to shutdown
• Provide facilities like disk checking, process scheduling, error
logging, printing
• Run in user context not kernel context
• Known as services, subsystems, daemons

• Application programs
• Don’t pertain to system
• Run by users
• Not typically considered part of OS
• Launched by command line, mouse click, finger poke
System Calls
• Programming interface to the services provided
by the OS
• Typically written in a high-level language (C or
C++)
• Mostly accessed by programs via a high-level
Application Programming Interface (API)
rather than direct system call use
• Three most common APIs are Win32 API for
Windows, POSIX API for POSIX-based
systems (including virtually all versions of
UNIX, Linux, and Mac OS X), and Java API for
the Java virtual machine (JVM)
Note that the system-call names used throughout this
text are generic
Example of System Calls

• System call sequence to copy the contents of one


file to another file
Example of Standard API
System Call Implementation
• Typically, a number associated with each system call
• System-call interface maintains a table indexed according to
these numbers
• The system call interface invokes the intended system
call in OS kernel and returns status of the system call
and any return values
• The caller need know nothing about how the system
call is implemented
• Just needs to obey API and understand what OS will do as a
result call
• Most details of OS interface hidden from programmer by
API
• Managed by run-time support library (set of functions built into
libraries included with compiler)
API – System Call – OS Relationship
System Call Parameter Passing
• Often, more information is required than simply
identity of desired system call
• Exact type and amount of information vary according to OS
and call
• Three general methods used to pass parameters to the
OS
• Simplest: pass the parameters in registers
• In some cases, may be more parameters than registers
• Parameters stored in a block, or table, in memory, and address
of block passed as a parameter in a register
• This approach taken by Linux and Solaris
• Parameters placed, or pushed, onto the stack by the program
and popped off the stack by the operating system
• Block and stack methods do not limit the number or length of
parameters being passed
Parameter Passing via Table
Types of System Calls
• Process control
• create process, terminate process
• end, abort
• load, execute
• get process attributes, set process attributes
• wait for time
• wait event, signal event
• allocate and free memory
• Dump memory if error
• Debugger for determining bugs, single step execution
• Locks for managing access to shared data between processes
Types of System Calls
• File management
• create file, delete file
• open, close file
• read, write, reposition
• get and set file attributes
• Device management
• request device, release device
• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices
Types of System Calls (Cont.)
• Information maintenance
• get time or date, set time or date
• get system data, set system data
• get and set process, file, or device attributes
• Communications
• create, delete communication connection
• send, receive messages if message passing model to host
name or process name
• From client to server
• Shared-memory model create and gain access to memory
regions
• transfer status information
• attach and detach remote devices
Types of System Calls (Cont.)

• Protection
• Control access to resources
• Get and set permissions
• Allow and deny user access
Examples of Windows and Unix System Calls
Standard C Library Example
• C program invoking printf() library call, which calls
write() system call
Example: MS-DOS
• Single-tasking
• Shell invoked when
system booted
• Simple method to run
program
• No process created
• Single memory space
• Loads program into
memory, overwriting all
but the kernel At system startup running a
program
• Program exit -> shell
reloaded
Example: FreeBSD
• Unix variant
• Multitasking
• User login -> invoke user’s choice
of shell
• Shell executes fork() system call to
create process
• Executes exec() to load program into
process
• Shell waits for process to terminate
or continues with user commands
• Process exits with:
• code = 0 – no error
• code > 0 – error code
Operating System Design and Implementation

• Design and Implementation of OS not “solvable”, but


some approaches have proven successful

• Internal structure of different Operating Systems can


vary widely

• Start the design by defining goals and specifications

• Affected by choice of hardware, type of system

• User goals and System goals


• User goals – operating system should be convenient to use,
easy to learn, reliable, safe, and fast
• System goals – operating system should be easy to design,
implement, and maintain, as well as flexible, reliable, error-
Operating System Design and Implementation (Cont.)

• Important principle to separate


Policy: What will be done?
Mechanism: How to do it?
• Mechanisms determine how to do something,
policies decide what will be done
• The separation of policy from mechanism is a very
important principle, it allows maximum flexibility if
policy decisions are to be changed later (example –
timer)
• Specifying and designing an OS is highly creative
task of software engineering
Implementation

• Much variation
• Early OSes in assembly language
• Then system programming languages like Algol, PL/1
• Now C, C++
• Actually usually a mix of languages
• Lowest levels in assembly
• Main body in C
• Systems programs in C, C++, scripting languages like PERL,
Python, shell scripts
• More high-level language easier to port to other hardware
• But slower
• Emulation can allow an OS to run on non-native hardware
End of Chapter 1

You might also like