0% found this document useful (0 votes)
24 views

Introduction To OS

An operating system is software that manages computer hardware resources and provides common services for computer programs. It acts as an intermediary between users and the computer hardware. The key roles of an operating system include managing processes, memory, secondary storage, input/output devices, and files. It allows for the sharing of resources and prevents interference between processes. An operating system provides an interface for users and a programming interface for applications through system calls.

Uploaded by

Glrmn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Introduction To OS

An operating system is software that manages computer hardware resources and provides common services for computer programs. It acts as an intermediary between users and the computer hardware. The key roles of an operating system include managing processes, memory, secondary storage, input/output devices, and files. It allows for the sharing of resources and prevents interference between processes. An operating system provides an interface for users and a programming interface for applications through system calls.

Uploaded by

Glrmn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Introduction to Operating System

1
Block Diagram of a Computer (Logical)

2
Operating System (OS)
• What do you do with just computer hardware?
– If someone gives you a computer with no software
whatsoever, how do you get it to do anything?
– You write a program that runs on the hardware

• In the early days, that was the way it worked ...


– You started with just the bare hardware
– You wrote a program that did everything:
• Including managing all aspects of the hardware
• Including solving your particular problem

• Your program was all the computer did!

3
Without an OS
• Each program runs directly on the hardware
• Each program must do everything
• Each program needs to know the details of the hardware and
how to use it
• If the hardware changes, the program must change as well
• The hardware supports only one program at a time - each
user must wait until the previous program is done to “share”
the hardware with other users.
• Writing programs is incredibly complex and expensive
• OS is like an extended machine to provide a better interface
for convenience.

4
Four Components of a Computer System:

5
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

6
Operating System (OS)
• Integrated set of programs that controls the resources of a
computer system
• Provides its users with an interface which is more convenient
to use than bare machine
• Directly sits on top of the hardware and controls it
• Manages computer hardware
• Provides a basis for application programs
• Acts as an intermediary between computer user and
computer hardware

7
Introduction
• “An operating system is similar to a government. Like a
government, it performs no useful function by itself. It simply
provides an environment within which other programs can do
useful work”

• “The fundamental goal of computer systems is to execute user


programs and to make solving user problems easier”

8
Views of an Operating System

• Resource Allocator
– Operating system manages or allocates resources
– What resources?
• CPU time, RAM Memory, disk & other I/O devices, interrupt
numbers (IRQ’s), files, network ports & sockets, and other
software resources
– Who uses the resources?
• Resource users: One or more user processes & threads
• Control Program
– Operation and control of hardware devices
– Implements security and protection
– Execution of user program to prevent errors and prevent improper
use of the computer

9
Goals of an OS
⚫ Execute user programs and make solving user
problems easier
⚫ Make the computer system convenient to use
⚫ Use the computer resources in an efficient
manner
⚫ Ability to evolve
⚫ Can you think of reasons which make evolution
necessary?
⚫ H/W changes, new services, fixes
⚫ Different design goals for different OS
⚫ Mainframes, PC, Handheld

10
The Role of an OS
• A computer is a set of resources for the movement, storage, and
processing of data.
• The OS is responsible for managing these resources.

11
Operating System as Software

•The OS functions in the same way as an ordinary computer software

•It is a program that is executed by the CPU

•The OS frequently relinquishes control and must depend on the


processor to allow it to regain control.

12
OS as Resource Manager

13
Common Tasks by OS

14
Basic function of OS:

• Process Management

• Main memory management

• Secondary storage management

• I/O Subsystem Management

• File Management

15
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
■ 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

16
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

17
2. Main Memory Management
■ Main memory -array of words/bytes

■ All data in memory before and after processing

■ All instructions in memory in order to execute

■ Memory management determines what is in memory 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

18
3. Secondary Storage Management
■ Main memory is small and volatile
■ Secondary storage is large and nonvolatile

❑ OS activities related to disk management include


■ Free space management
■ Storage allocation
■ Disk scheduling

19
4. I/O Subsystem management
■ 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

20
5. File 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

21
FS Management Activities
❑ Creating and deleting files
❑ Creating and deleting directories
❑ Supporting primitives for manipulating files and directories
❑ Mapping files onto secondary storage
❑ Backing up files on stable (non-volatile) storage media

i
OS Services

A view of OS services
23
User – OS Interface
• GUI
– Graphical User Interface
– Desktop, icons, mouse
• CLI
– Command Line Interface
– Allows direct command entry
– Sometimes implemented in kernel, sometimes by systems
program
– Command interpreter
– Windows: Command shell
– UNIX/LINUX: Terminal – bash, ksh, csh: shells
– Built-in commands vs external commands
System Calls
• There are two modes in the computer system one is user mode and
another is kernel mode.
• In computer system there are different types of processes that are running
on a computer system.
• When a user runs an application it is said to be in user mode or computer
is in user mode.
• When there is a requirement of hardware resource, the process sends a
request to the kernel to get the process access and then computer enters
in kernel mode.
• These requests are sent by using system call.
• The computer switches between these two mode frequently. Whenever
the task is completed the computer goes back to the user mode from
kernel mode. This mode of transition is called context switching.

25
System Calls
❑ User programs are not allowed to access system resources
directly. They must ask the OS to do that for them.

❑ OS provides a set of functions that can be called by user


programs to request for OS services. These functions are called
“system calls”
❑ System calls run in kernel mode.

❑ They can be called by executing a special instruction (trap or


software interrupt) which causes processor to switch to the kernel
mode and jump to a previously defined location in the kernel.

❑ When the system call finishes, processor returns to the user


program and runs in user mode.

26
Dual Mode Operation

Figure : Transition from User to Kernel Mode

Kernel mode is also called Supervisor mode


System Calls
■ System calls provide the interface between a running program and the
operating system.

■ Generally available as assembly-language instructions.

■ Languages defined to replace assembly language for systems programming


allow system calls to be made directly (e.g., C, C++)

■ Mostly accessed by programs via a high-level Application Program 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)

■ Why use APIs rather than system calls?

28
API
• An API is a set of functions provided by an operating
system or other system software.
• An application program calls the functions to request the
services.
• An API clearly defines how to call functions and what the
results are. (API is specification, not implementation)
• Examples: APIs for file system, graphics user interface,
networking, etc

29
Types of System Calls : There are 5 different categories of system calls –
1. Process control: end, abort, create, terminate, allocate and free
memory.
2. File management: create, open, close, delete, read file etc.
3. Device management
4. Information maintenance
5. Communication
API – System Call – OS Relationship

31
Standard C Library Example
■ C program invoking printf() library call, which calls write() system call

32
Examples of Windows and Unix System Calls

33

You might also like