0% found this document useful (0 votes)
12 views94 pages

Introduction to Operating Systems Basics

Uploaded by

mshivanisri786
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)
12 views94 pages

Introduction to Operating Systems Basics

Uploaded by

mshivanisri786
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

UNIT 1- Operating Systems

Overview

[Link]
AP/AI
Introduction –Chapter1

 What Operating Systems Do


 Computer-System Organization
 Computer-System Architecture
 Operating-System Operations
 Resource Management
 Security and Protection
 Virtualization
 Computing Environments
What is an Operating System?

• Some of OS are designed to Convenient and others to be efficient


• Some OS provides Both
Convenient – It is the interface between user and hardware
Efficient - Allocation of resources
Both – Management of resources and security etc
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
Abstract View of Components of Computer
What Operating Systems Do
 Depends on the point of view 1. User view 2. System view
 User view - Users want convenience, ease of use and good performance-
Don’t care
about resource utilization
System view - Operating system is a resource allocator and control
program making efficient use of Hardware and managing execution of
user programs
 Some computers have little or no user interface, such as embedded
computers in devices and automobiles -Run primarily without user
intervention
Operating System Definition
 A more common definition is , that the operating system is the one
program running at all times on the computer—usually called
the kernel.
 Along with the kernel, there are two other types of programs:
system programs, which are associated with the operating
system but are not necessarily part of the kernel, and
application programs, which include all programs not associated
with the operation of the system.
 Today’s OSes for general purpose and mobile computing also
include
 middleware – a set of software frameworks that provide
additional services to application developers such as databases,
multimedia, graphics
Computer System Organization
 Computer-system operation
• One or more CPUs, device controllers connect through common
bus providing access to shared memory
• Concurrent execution of CPUs and devices competing for
memory cycles
Computer-System Operation

 I/O devices and the CPU can execute concurrently


 Each device controller is in charge of a particular device type
 Each device controller has a local buffer
 Each device controller type has an operating system
device driver to manage it
 CPU moves data from/to main memory to/from local
buffers
 I/O is from the device to local buffer of controller
 Device controller informs CPU that it has finished its
operation by causing an interrupt
Computer Startup - Bootstrap

or EPROM, known as firmware


Common Functions of Interrupts

• Interrupt transfers control to the interrupt service routine generally,


through the interrupt vector, which contains the addresses of all the
service routines
• Interrupt architecture must save the address of the interrupted
instruction
• A trap or exception is a software-generated interrupt caused either by
an error or a user request
• An operating system is interrupt driven
1. Interrupt Handling

 The operating system preserves the state of the CPU by


storing the registers and the program counter
 Determines which type of interrupt has occurred:
 Separate segments of code determine what action should be
taken for each type of interrupt
Interrupt Timeline
Interrupt-drive I/O Cycle
I/O Structure (Cont.)
 After I/O starts, control returns to user program only upon
I/O
completion
• Wait instruction idles the CPU until the next interrupt
• Wait loop (contention for memory access)
• At most one I/O request is outstanding at a
time, no simultaneous I/O processing
 After I/O starts, control returns to user program without waiting
for I/O completion
• System call – request to the OS to allow user to wait for I/O
completion
• Device-status table contains entry for each I/O
device indicating its type, address, and state
• OS indexes into I/O device table to determine device status
and to modify table entry to include interrupt
Interrupt Implementation
 The CPU hardware has a wire called the interrupt-request line that
the CPU senses after executing every instruction.
 When the CPU detects that a controller has asserted a signal on the
interrupt-request line, it reads the interrupt number and jumps to the
interrupt-handler routine by using that interrupt number as an
index into the interrupt vector.
 It then starts execution at the address associated with that index.
 The interrupt handler saves any state it will be changing during its
operation, determines the cause of the interrupt, performs the necessary
processing, performs a state restore, and executes a return from
interrupt instruction to return the CPU to the execution state prior to the
interrupt.
 Most CPUs have two interrupt request lines. One is the
nonmaskable interrupt, which is reserved for events. The second
interrupt line is maskable: it can be turned off by the CPU before
the execution of critical instruction sequences that must not be
interrupted.
Nonmaskable & maskable interrupt
 Non-Maskable Interrupt (NMI) is a type of hardware interrupt (or
signal to the processor) that prioritizes process. Unlike other types of
interrupts, the non-maskable interrupt cannot be ignored through the
use of interrupt masking techniques.
[Ex] user presses control, alt, delete to create an immediate signal to
the system when the computer is not responding.
 Maskable Interrupt : An Interrupt that can be disabled or ignored by
the instructions of CPU are called as Maskable Interrupt. When an
interrupt of this type occurs, the system can handle it after it executes
the current instructions.
Design of the interrupt vector for Intel processors
 The events from
to 031, which are
nonmaskable, are
used to signal various
error conditions.
 The events from 32
to 255, which are
maskable, are used
for purposes such as
device-generated
interrupts.
Storage Structure
 Main memory – only large storage media that the CPU can access
directly
• Random access Typically volatile
• Typically random-access memory in the form of Dynamic
Random-access Memory (DRAM)
 Secondary storage – extension of main memory that provides
large
nonvolatile storage capacity
 Hard Disk Drives (HDD) – 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 cache for
secondary storage
 Device Driver for each device controller to manage I/O
• Provides uniform interface between controller and
kernel
Storage-Device Hierarchy
How a Modern Computer Works

A von Neumann architecture


To solve this problem Direct
Memory Access (DMA) is
used

 Used for high-speed I/O


devices able to transmit
information at close to
memory speeds
 Device
controller transfers
blocks
from of data storage
buffer
directly to main
memory without CPU
intervention
 Only interrupt is
one per
generated
rather than the blo
interrupt per byte ck,
Computer System Architecture
Computer-System Architecture

 Single Processor System


 Multi Processor System
 Clustered Systems
Computer-System Architecture
Single Processor System
 Many ago, most computer
systems
years used a single processor
containing one CPU with a single
processing core. The core is the
component that executes instructions
and registers for storing data locally.
The one main CPU with its core
is capable of executing a general-
purpose instruction set, including
instructions from processes.
All of these special-purpose
These systems have other processors run a limited
special- purpose processors. They may instruction set and do not run
come in the form of device-specific processes. Sometimes, they
processors, such as disk, keyboard, are managed by the operating
and graphics controllers. system
Computer-System Architecture
 Multiprocessor systems: On modern computers, from mobile
devices to servers is available. Traditionally, such systems have two
(or more) processors, each with a single-core CPU. The processors
share the computer bus and sometimes the clock, memory, and
peripheral devices. Also known as parallel systems, tightly-coupled
systems
• Advantages include:
1. Increased throughput - Speedup ratio: N processor is not N,
However less than N
2. Economy of scale – cost is less than equivalent multiple
single processor systems (Because they can share their
peripherals)
3. Increased reliability – graceful degradation or fault tolerance
• Two types:
1. Asymmetric Multiprocessing – each processor is assigned a
specific task.
Symmetric Multiprocessing Architecture(SMP)
• Each CPU processor
performs all tasks, including
operating-system functions
and user processes. Each CPU
processor has its own set of
registers and local cache.

• However, all processors


share physical memory over
the system bus.

• The benefit of this model is


that many processes can run
simultaneously N processes
can run if there are N CPUs.
Dual-Core Design
 Each core has its own register set,
as well as its own local cache,
often known as a level 1, or L1,
cache.
 Level 2 (L2) cache is local to the
chip but is shared by the two
processing cores.
 Most architectures adopt this
approach, combining local and
shared caches, where local,
lower-level caches are generally
smaller and faster than higher-
level shared caches.
Clustered Systems
 Like multiprocessor systems, but multiple systems working
together
• Usually sharing storage via a storage-area network (SAN)
• Provides a high-availability service which survives failures
Asymmetric clustering has one machine in hot-standby
mode [ Monitoring other machines]
Symmetric clustering has multiple nodes running
applications, monitoring each other
• Some clusters are for high-performance computing (HPC)
Applications must be written to use parallelization
• Some have distributed lock manager (DLM) to avoid
conflicting operations
Clustered Systems
1. Batch OS : Sequence of jobs in a program on a computer without manual
interventions. There is an operator which takes similar jobs having
the same requirement and group them into batches. It is the
responsibility of the operator to sort jobs with similar needs.
There is no interaction between user and CPU
Examples of Batch based Operating System: Payroll System, Bank
Statements, etc
2. Time-Sharing Operating Systems – Each task is given some time to
execute so that all the tasks work smoothly. Each user gets the time of
CPU as they use a single system. These systems are also known as
Multitasking Systems. The task can be from a single user or different
users also. The time that each task gets to execute is called quantum.
After this time interval is over OS switches over to the next task.
Examples of Time-Sharing OSs are: Multics, Unix, etc.
3. Distributed Operating System – These types of the operating system is a
recent advancement in the world of computer technology and are
being widely accepted all over the world. Various autonomous
interconnected computers communicate with each other using a shared
communication network. Independent systems possess their own
memory unit and CPU.
4. Network Operating System – These systems run on a server and
provide the capability to manage data, users, groups, security,
applications, and other networking functions. These types of operating
systems allow shared access of files, printers, security, applications,
and other networking functions over a small private network.
Examples of Network Operating System are: Microsoft Windows
Server 2003, Microsoft Windows Server 2008, UNIX, Linux, Mac OS
X, Novell NetWare, and BSD, etc.
5. Real-Time Operating System – These types of OSs serve real-time
systems. The time interval required to process and respond to
inputs is very small. This time interval is called response
time. Real-time systems are used when there are time requirements
that are very strict like missile systems, air traffic control systems,
robots,
Examples of Real-Time Operating Systems are: Scientific
experiments, medical imaging systems, industrial control systems,
weapon systems, robots, air traffic control systems, etc.
6. Multiprogramming/ tasking / processing : CPU is a super fast
device and keeping it occupied for a single task is never a good idea.
Considering the huge differences between CPU speed and IO speed,
many concepts like multiprogramming, multitasking, multithreading,
etc have been introduced to make better CPU utilization.
Multi programming:- Multi-programming increases CPU utilisation
by organising jobs (code and data) so that the CPU always has
one to execute. The idea is to keep multiple jobs in main memory. If
one job gets occupied with IO, CPU can be assigned to other job.
Multi-tasking:- It is a logical extension of multiprogramming.
Multitasking the ability of an OS to execute more than
one task simultaneously on a CPU machine. These multiple tasks
is
share common resources (like CPU and memory). In multi-tasking
systems, the CPU executes multiple jobs by switching among them
typically using a small time quantum, and the switches occur so
quickly that the users feel like interact with each executing task at the
same time.
Difference between Multiprogramming and Multi-tasking
[Link] Multiprogramming Multi-tasking

1. Both of these concepts are for Both of these concepts are for single CPU.
single CPU.

2. Concept of Context Switching Concept of Context Switching and Time


is Sharing is used.
used.

3. In multiprogrammed system, the The processor is typically used in time


operating system simply switches sharing mode. Switching happens when
to, and executes, another job when either allowed time expires or where there
current job needs to wait. other reason for current process needs to
wait (example process needs to do IO).

4. Multi-programming increases In multi-tasking also increases CPU


CPU utilization by organising jobs utilization, it also increases responsiveness.
.

5. The idea is to reduce the CPU idle The idea is to further extend the CPU
time for as long as possible. Utilization concept by increasing
responsiveness Time Sharing.
Operating-System Operations
 A computer to start running—for instance, when it is powered up or
rebooted—it needs to have an initial program to run. This initial
program is bootstrap program and it is stored within the computer
hardware(ROM) or EPROM as firmware.
 Bootstrap program – simple code to initialize the system, load
the kernel
 Once the kernel is loaded and executing, it can start providing services
to the system and its users. Some services are provided outside of
the kernel by system programs that are loaded into memory at
boot time to become system daemons, which run the entire time
the kernel is running.
 On Linux, the first system program is ―systemd,‖ and it starts many
other daemons. Once this phase is complete, the system is fully
booted, and the system waits for some event to occur.
 Events are always signaled by the occurrence of an interrupt.
Operating-System Operations
 The interrupts are from both hardware and software
• Hardware interrupt by one of the devices
• Software interrupt (exception or trap):
Software error (e.g., division by zero)
a specific request from a user program that an operating-system
service be performed by executing a special operation called a
system call.
Otherprocess problems include infinite loop, processes
modifying each other

The OS operations are ,


1. Multiprogramming and Multi tasking
2. Dual mode and Multimode operation
3. Timer
i) Multiprogramming and Multitasking (Timesharing)
Multiprogramming
 One of the most important aspects of operating systems is the ability to
run multiple programs, as a single program cannot keep either the CPU
or the I/O devices busy at all times.
 Furthermore, users want to run more than one program at a time as
well. Multiprogramming increases CPU utilization,
 In a multiprogrammed system, a program in execution is termed a
process.
Multitasking (Timesharing)
• The 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
2. Dual-mode and Multi mode Operation
 Dual-mode operation allows OS to
protect itself and other system
components
 User mode and kernel mode[(also called
as supervisor mode, system mode, or
privileged mode).
 Mode bit provided by hardware
 Provides ability to distinguish when
system is running user code or kernel
code.
 When a user is running  mode bit is
―user‖ [No direct access to memory,
h/w]
 When kernel code is executing

mode bit is ―kernel‖
 System call changes mode to kernel
mode, return from call resets it to user
Transition from User to Kernel Mode

Some instructions designated as privileged [direct access to memory,


h/w] , only executable in kernel mode
Need for user mode : When a program is executing in kernel mode,
and if that program happens to crash during its execution then the
entire system would to crash. This is the problem of kernel mode.
But if the program is executing in user mode, and if it crashes the
entire system does not crash. So, user mode is safe mode.
Multimode
 The concept of modes can be extended beyond two modes. For
example, Intel processors have four separate protection rings,
where ring 0 is kernel mode and ring 3 is user mode. Rings 1
and 2 could be used for various operating-system services, in
practice they are rarely used.
 ARMv8 systems have seven modes. CPUs that support
virtualization frequently have a separate mode to indicate when the
virtual machine manager (VMM) is in control of the system. In
this mode, the VMM has more privileges than user mode but
fewer than the kernel mode.
3. Timer
 Timer to prevent infinite loop [or process hogging resources]
(hogging - to take or use more than necessary of something)
• 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 is zero, it generate an interrupt
• Set up before scheduling process to regain control or
terminate program that exceeds allotted time
Resource Management
1. Process Management
2. Memory Management
3. File-system Management
4. Mass-Storage Management
5. Cache Management
6. I/O Subsystem
1. Process Management
 A process is a program in execution. It is a unit of work within the
system. Program is a passive entity; process is an active entity.
 Process needs resources to accomplish its task
• CPU, memory, I/O, files, Initialization data
 Process termination requires reclaim of any
reusable resources
 Single-threaded process has one program counter specifying
location of next instruction to execute
• Process executes instructions sequentially, one at a time,
until completion
 Multi-threaded process has one program counter per thread
 A system consists of a collection of processes, some of which are
operating-system processes (those that execute system code) and
the user processes (those that execute user code). All these
processes can potentially execute concurrently—by multiplexing on
Process Management Activities
The operating system is responsible for the following activities
in connection with process management:
• Creating and deleting both user and system processes
• Suspending and resuming processes
• Providing mechanisms for process synchronization
• Providing mechanisms for process communication
• Providing mechanisms for deadlock handling
2. Memory Management
 To execute a program, all (or part) of the instructions must be
in
memory
 Memory management determines what is in memory
• Optimizing CPU utilization and response time to users
Memory management activities
 Keeping track of which parts of memory are currently being used
and which process is using them
 Allocating and deallocating memory space as needed
 Deciding which processes and data to move into and out
of memory
3. File-system Management
 OS provides uniform, logical view of information storage
• Abstracts physical properties of a file to logical storage unit
• Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include access speed, capacity, data-transfer
rate, access method (sequential or random)
 File-System management
• Files usually organized into directories
• Access control on most systems to determine who can access what
• OS activities include
Creating and deleting files and directories
Primitives to manipulate files and directories

Mapping files onto secondary storage

Backup files onto stable (non-volatile) storage media


4. Mass-Storage Management
 Usually disks used to store data that does not fit in main memory
or data that must be kept for a “long” period of time
 Proper management is of central importance
 Entire speed of computer operation hinges on disk subsystem
and its algorithms
 OS activities
• Mounting and unmounting
• Free-space management
• Storage allocation
• Disk scheduling
• Partitioning
• Protection
5. Cache Management
 Important principle, performed at many levels in a computer (in
hardware, operating system, software)
 Information in use copied from slower to faster storage
temporarily
 Faster storage (cache) checked first to determine if information is
there
• If it is, information used directly from the cache (fast)
• If not, data copied to cache and used there
 Cache smaller than storage being cached
• Cache management important design problem
• Cache size and replacement policy
Characteristics of Various Types of Storage

Movement between levels of storage hierarchy can be explicit or


implicit
Migration of data “A” from Disk to Register
 Multitasking environments must be careful to use most
recent value, no matter where it is stored in the storage
hierarchy

 Multiprocessor environment must provide cache coherency in


hardware such that all CPUs have the most recent value in
their cache
 In a distributed environment, the situation becomes even more
complex . In this environment, several copies (or replicas) of
the same file can be kept on different computers. Since the
various replicas may be accessed and updated
concurrently, some distributed systems ensure that, when a
replica is updated in one place, all other replicas are brought
up to date as soon as possible.
6. I/O Subsystem
 One purpose of OS is to hide peculiarities of hardware devices
from the user
 I/O subsystem responsible for
• Memory management of I/O including buffering (storing data
temporarily while it is being transferred), caching (storing
parts of data in faster storage for performance), spooling (the
overlapping of output of one job with input of other jobs)
• General device-driver interface
• Drivers for specific hardware devices
Protection and Security
 Protection – any mechanism for controlling access of processes or
users to resources defined by the OS
 Security – defense of the system against internal and external attacks
• Huge range, including denial-of-service, worms, viruses, identity
theft, theft of service
 Systems generally first distinguish among users, to determine who
can
do what
• User identities (user IDs, security IDs) include name
and associated number, one per user
• User ID then associated with all files, processes of that user
to determine access control
• Group identifier (group ID) allows set of users to be defined and
controls managed, then also associated with each process, file
• Privilege escalation allows user to change to effective ID with
more rights
Virtualization
 Allows operating systems to run applications within other OSes
• Vast and growing industry
 Emulation, which involves simulating computer hardware in
software, is typically used when the source CPU type is different
from the target CPU type. For example, when Apple switched from
the IBM Power CPU to the Intel x86 CPU for its desktop and laptop
computers, it included an emulation facility called ―Rosetta,‖ which
allowed applications compiled for the IBM CPU to run on the Intel
CPU. Emulation comes at a heavy price.
 Virtualization is used the hardware of a single computer( CPU,
Memory, disk, network interface card) into several execution
environments, thereby creating illusion that each separate execution
environment is running its own private computer. OS natively
compiled for CPU, running guest OSes also natively compiled
 [Ex]:VMware running WinXP guests, each running applications, all on
native WinXP host [Link] (virtual machine Manager) provides
virtualization services
Virtualization (cont.)
 Use cases involve laptops and desktops running multiple OSes for
exploration or compatibility
• Apple laptop running Mac OS X host, Windows as a guest
• Developing apps for multiple OSes without having multiple
systems
• Quality assurance testing applications without having
multiple systems
• Executing and managing compute environments within
data centers
 VMM can run natively, in which case they are also the host
• There is no general-purpose host then (VMware ESX and Citrix
XenServer)
Computing Environments - Virtualization
Non Virtual machine Virtual machine

Windows

Linux

Ubuntu

Apple
hardware
with MAC
OS
Apple
hardware
with MAC
OS
Computer System Environments
Computing Environments

 Traditional
 Mobile
 Client Server
 Pear-to-Pear
 Cloud computing
 Real-time Embedded
Traditional
 Stand-alone general-purpose machines
 But most systems interconnect with others (i.e., the Internet)
 Portals provide web access to internal server systems
 Network computers (thin clients) which are essentially terminals
that understand web-based computing— are used in place of
traditional workstations where more security or easier maintenance
is desired.
 Mobile computers interconnect via wireless networks
 Networking becoming ubiquitous – even home systems use
firewalls to protect home computers from Internet attacks
Mobile
 Handheld smartphones, tablets, etc.
 The functional difference between mobile and a ―traditional‖
laptop is – more OS features (GPS, gyroscope)
 Allows new types of apps like augmented reality
 Use IEEE 802.11 wireless, or cellular data networks for
connectivity
 Leaders are Apple iOS and Google Android
Client Server
 Client-Server Computing
• Dumb terminals supplanted by smart PCs
• Many systems now servers, responding to requests generated
by clients
Compute-server system provides an interface to client to
request services (i.e., database)
File-server system provides interface for clients to store and
retrieve files
Peer-to-Peer
 Another model of distributed system with
no centralized service
 P2P does not distinguish clients and
servers
• Instead all nodes are considered
peers
• May each act as client, server or
both
• Node must join P2P network
Registersits service with central
lookup service on network, or
Broadcast request for service and
respond to requests for service via
discovery protocol
• Examples include Napster and
Cloud Computing

 Delivers computing, storage, even apps as a service across a


network
 Logical extension of virtualization because it uses virtualization as
the base for it functionality.
• Amazon EC2 has thousands of servers, millions of virtual
machines, petabytes of storage available across the Internet,
pay based on usage
Cloud Computing (Cont.)
 Many types
• Public cloud – available via Internet to anyone willing to pay
• Private cloud – run by a company for the company’s own use
• Hybrid cloud – includes both public and private
cloud components
• Software as a Service (SaaS) – one or more applications
available via the Internet (i.e., word processor)
• Platform as a Service (PaaS) – software stack ready
for application use via the Internet (i.e., a database
server)
• Infrastructure as a Service (IaaS) – servers or storage
available
over Internet (i.e., storage available for backup use)
Cloud Computing (cont.)
 Cloud computing environments composed of traditional OSes,
plus
VMMs, plus cloud management tools
• Internet connectivity requires security like firewalls
• Load balancers spread traffic across multiple applications
Real-Time Embedded Systems
 Embedded computers are the most prevalent form of computers in
existence. These devices are found everywhere, from car engines,
robots and microwave ovens. They tend to have very specific tasks.
The systems they run on are usually primitive, and so the operating
systems provide limited features. Usually, they have little or no user
interface, preferring to spend their time monitoring and managing
hardware devices.
 Many other special computing environments as well
• Some have OSes, some perform tasks without an OS
 Real-time OS has well-defined fixed time constraints
• Processing must be done within constraint
• Correct operation execute , only if constraints met
Free and Open-Source Operating Systems
 Operating systems made available in source-code format rather than
just binary closed-source and proprietary[Ex: Windows]
 Counter to the copy protection and Digital Rights
Management
(DRM) movement
 Started by Free Software Foundation (FSF), which has “copyleft”
GNU Public License (GPL)
• Free software and open-source software are two different ideas
championed by different groups of people
[Link]
 Examples include GNU/Linux and BSD UNIX, and many more
 Can use VMM like VMware Player (Free on Windows), Virtualbox
(open source and free on many platforms
- [Link]
• Use to run guest operating systems for exploration
Operating-System Services – chapter2

 Operating system services


 User and Operating System-Interface
 System Calls
Operating System Services
Operating systems provide an environment for execution of programs
and services to programs and users
1. 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 Interface (CLI), Graphics
User Interface (GUI), touch-screen
• 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
• File-system manipulation - Programs need to read and write
files and directories, create and delete them, search them,
list file Information, permission management.
Operating System Services (Cont.)
• 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 [ex- paper out in
printer]
Debugging facilities can greatly enhance the user ’ s and
programmer’s abilities to efficiently use the system
Operating System Services (Cont.)
2. 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.
• Logging - 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
A View of Operating System Services
Command Line Interface or Command Interpreter
 CLI allows direct command entry – text based commands [eg-
command prompt in windows, terminal in Linux] – user has to
remember all the commands to perform tasks
 Some OS implemented in kernel, some OS treat CLI as systems
program like windowsXP
 Sometimes multiple command interpreters are implemented in
Linux – called as shells
 eg – Bourne shell
 C shell
 Bourne -Again shell(BASH)
 Korn shell
 Primarily fetches a command from user and executes it
 Sometimes commands built-in, sometimes just names of
programs
Command Interpreter in Windows – create and delete directory
1. Type cmd in search
2. Type ― cd desktop‖
3. Type ―mkdir jp‖
4. Check the desktop , the directory is there or not
5. Or type ―dir‖ [ list the directories is in
desktop]
6. Type ―rmdir jp‖

Some network commands


1. Ipconfig
2. Ping
3. Hostname
4. Getmac
5. arp
User Operating System Interface - GUI
 User-friendly desktop interface
• Usually mouse, keyboard, and monitor
• Icons represent files, programs, actions, etc
• Various mouse buttons over objects in the interface cause
various actions (provide information, options, execute function,
open directory (known as a folder)
• Invented at Xerox PARC
 Many systems now include both CLI and GUI interfaces
• Microsoft Windows is GUI with CLI “command” shell
• Apple Mac OS X is “Aqua” GUI interface with UNIX kernel
underneath and shells available
• Unix and Linux have CLI with optional GUI interfaces (CDE,
KDE, GNOME)
Touchscreen Interfaces
 Touchscreen devices require
new interfaces
• Mouse not possible or not
desired
• Actions and selection
based on gestures
• Virtual keyboard for text
entry
 Voice commands
System Calls
• System calls provide an interface to the services made available by
an operating system.

• These calls are generally available as functions written in C and C++.

• Mostly accessed by programs via a high-level Application


Programming Interface (API) rather than direct system call
 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)
 System call to copy the contents of one file to another file in Unix
cp [Link] [Link]
Example of System Call sequence in GUI to make
copy the contents
 System call sequence to copy the contents of one file
to another file
Example of Standard API
System Call Implementation

 Typically, a number is 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 (Cont.)
 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
From client to server
• Shared-memory model create and gain access to memory regions
• transfer status information
• attach and detach remote devices
 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
System call for process control
 Two or more processes may share data. To ensure the integrity of the
data being shared, operating systems often provide system calls
allowing a process to lock shared data. Then, no other process can access
the data until the lock is released. Typically, such system calls include
acquire lock() and release lock().
 There are so many variations in process control. Two examples— one
involving a single-tasking system and the other a multitasking
system

1. Single tasking – [ex] - Arduino


Arduino is an open-source platform consisting of a
microcontroller along with input sensors that respond to a variety of
events based on easy-to-use hardware and software. Arduino are
able to read inputs - light on a sensor, a finger on a button - and
turn it into an output - activating a motor, turning on an LED
• To write a program for Example: Arduino
the Arduino, first write
program on a PC and then
the
upload the compiled program
(known as a sketch) from the
PC to the Arduino’s flash
memory via a USB
connection.
• The standard Arduino platform
does not provide an
operating system; instead,
a small piece of software At system startup running a program
known as a boot loader
loads the sketch into a • An Arduino is considered
specific region . in
Arduino’s memory the a
• Once the sketch has been one sketch can
single-tasking be present
system, in
as only
loaded, it begins running, memory at a time; if another
waiting for the events that it is sketch is loaded, it replaces the
programmed to respond to. existing sketch.
Example: FreeBSD
 Unix variant
 Multitasking
 User login -> invoke user’s
choice of shell [ 4 shells in
Linux]
 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

You might also like