1-Intro To OS

Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

Introduction to Operating

Systems
Computer
• A computer is an electronic device that manipulates
information or data. It has the ability to store, retrieve, and
process data.
• Generations of Computer:
– First generation (1946-1959) – Vacuum tubes
– Second generation (1959-1965) - Transistors
– Third generation (1965-1971) – ICs
– Fourth generation (1972- 1980) - Microprocessors
– Fifth generation (1980-till) – ULSI, AI
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
Operating System Definition
• User view
– OS is designed for ease of use
– OS is designed to maximize resource utilization

• System view
– OS is a resource allocator
• Manages all resources
• Decides between conflicting requests for efficient and fair resource use
– OS is a control program
• Controls execution of programs to prevent errors and improper use of the
computer
Operating System Definition (Cont.)
• No universally accepted definition
• “Everything a vendor ships when you order an operating
system” is good approximation
– But varies wildly
• “The one program running at all times on the computer” is
the kernel. Everything else is either a system program (ships
with the operating system) or an application program
Mainframe Systems
• Reduce setup time by batching similar jobs
• Automatic job sequencing – automatically transfers control
from one job to another. First rudimentary operating system.
• Resident monitor
– initial control in monitor
– control transfers to job
– when job completes control transfers pack to monitor
• Batch systems
• Multiprogrammed batch systems
• Multi-tasking systems
Mainframe Systems (cont.)
• Batch systems • Multiprogrammed batch systems
– Several jobs are kept in main memory at the
same time, and the CPU is multiplexed among
them.
OS Features Needed for
Multiprogramming
• I/O routine supplied by the system.
• Memory management – the system must allocate the
memory to several jobs.
• CPU scheduling – the system must choose among several jobs
ready to run.
• Allocation of devices.
Time-Sharing Systems–Interactive
Computing
• The CPU is multiplexed among several jobs that are kept in
memory and on disk (the CPU is allocated to a job only if the
job is in memory).
• A job swapped in and out of memory to the disk.
• On-line communication between the user and the system is
provided; when the operating system finishes the execution of
one command, it seeks the next “control statement” from the
user’s keyboard.
• On-line system must be available for users to access data and
code.
Desktop Systems
• Personal computers – computer system dedicated to a single
user.
• I/O devices – keyboards, mice, display screens, small printers.
• User convenience and responsiveness.
• Can adopt technology developed for larger operating system’
often individuals have sole use of computer and do not need
advanced CPU utilization of protection features.
• May run several different types of operating systems
(Windows, MacOS, UNIX, Linux)
Parallel Systems
• Multiprocessor systems with more than on CPU in close
communication.
• Tightly coupled system – processors share memory and a
clock; communication usually takes place through the shared
memory.
• Advantages of parallel system:
– Increased throughput
– Economical
– Increased reliability
• graceful degradation
• fail-soft systems
Parallel Systems (Cont.)
• Symmetric multiprocessing (SMP)
– Each processor runs and identical copy of the operating system.
– Many processes can run at once without performance deterioration.
– Most modern operating systems support SMP

• Asymmetric multiprocessing
– Each processor is assigned a specific task; master processor schedules
and allocated work to slave processors.
– More common in extremely large systems
Distributed Systems
• Distribute the computation among several physical processors.
• Loosely coupled system – each processor has its own local memory;
processors communicate with one another through various
communications lines, such as high-speed buses or telephone lines.
• Advantages of distributed systems.
– Resources Sharing
– Computation speed up – load sharing
– Reliability
– Communications
Distributed Systems (cont.)
• Collection of separate, possibly heterogeneous, systems
networked together
– Network is a communications path, TCP/IP most common
• Local Area Network (LAN)
• Wide Area Network (WAN)
• Metropolitan Area Network (MAN)
• Personal Area Network (PAN)

• Network Operating System provides features between


systems across network
– Communication scheme allows systems to exchange messages
– Illusion of a single system
Distributed Systems (cont.)
• 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
Distributed Systems (cont.)
• Peer-to-Peer Systems: another model of
distributed system
• 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
• Registers its 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 Gnutella, Voice over IP
(VoIP) such as Skype
Clustered Systems
• Clustering allows two or more systems to share storage.
• Provides high reliability.
• Asymmetric clustering: one server runs the application while
other servers standby.
• Symmetric clustering: all N hosts are running the application.
Real-Time Systems
• Often used as a control device in a dedicated application such as
controlling scientific experiments, medical imaging systems,
industrial control systems, and some display systems.
• Well-defined fixed-time constraints.

• Hard real-time:
– Secondary storage limited or absent, data stored in short term memory, or
read-only memory (ROM)
– Conflicts with time-sharing systems, not supported by general-purpose
operating systems.

• Soft real-time
– Limited utility in industrial control of robotics
– Useful in applications (multimedia, virtual reality) requiring advanced
operating-system features.
Mobile Computing Systems
• Personal Digital Assistants (PDAs)
• Cellular telephones
• Tablets
• Issues:
– Limited memory
– Slow processors
– Small display screens.
Operating System Functions
• Process management
• Memory management
• File-system management
• Mass-storage management
• I/O subsystem
• Protection and security
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
• Typically system has many processes, some user, some operating system
running concurrently on one or more CPUs
– Concurrency by multiplexing the CPUs among the processes / threads
Process Management
• 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
Memory Management
• To execute a program all (or part) of the instructions must be in memory
• All (or part) of the data that is needed by the program must be in memory
• Memory management determines what is in memory and when
– Optimizing CPU utilization and computer response to users
• Memory management activities
– Keeping track of which parts of memory are currently being used and by
whom
– Deciding which processes (or parts thereof) and data to move into and out of
memory
– Allocating and deallocating memory space as needed
File-system Management
• OS provides uniform, logical view of information storage
– Abstracts physical properties to logical storage unit - file
– 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
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
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
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), 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 - 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.
Operating System Services (Cont.)
• One set of operating-system services provides functions that
are helpful to the user (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
– 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.
– 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 from invalid access attempts
A View of Operating System Services
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)
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 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 to 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 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

You might also like