Operating System and System
Programming(15B11CI412)
Introduction and Historical context of Operating Systems
COURSE OUTCOMES COGNITIVE LEVELS
Explain the fundamental concepts along with the various Remember Level (C1)
C311.1 components of operating systems and system programming.
Demonstrate various OS scheduling techniques and algorithms Understand Level (C2)
C311.2 for processes and threads.
Build and apply the various resource management techniques Apply Level (C3)
C311.3 of operating systems and their performance.
Apply the concept of IPC and describe various process Apply Level (C3)
C311.4
synchronization techniques in OS.
Compare various disk scheduling algorithms and utilize IO Analyze Level (C4)
C311.5
management techniques.
Choosethe appropriate OS design choices when building Create Level (C5)
C311.6
real-world systems.
Recommended Books
A layer that separates the applications
from hardware that access and provide
services to each applications to execute
safely and correctly.
Key Components Who manages these?
CPU
Memory Hard
Disk
I/0 devices 9
Place of the 0S
Programs
P1 P2 P3
Operating System
CPUs
Hardware Memory
I/O & Storage
Operating system controls and coordinates use of hardware among various applications and users
User view : Concerned with ease of use
System view : Resource utilization and to control user programs and I/O
10
Why do we need a special program, the 0S?
• Many programs share common hardware
• The access to common hardware needs to be regulated
• Hardware: CPU, memory, I/0 and storage
• Schedule the CPU
• Interface with devices
• Manage storage
• Manage memory
• Security
• Make it easy to build distributed systems
• Makes it easy to work with HW
11
Two Key Functions
Why is abstraction important? • Abstract Machine
• Resource Manager
•Without OS and abstract interfaces, application writers must
program all device access directly
•Applications suffer severe code bloat!
•very complicated maintenance and upgrading
•no portability
16
Two Key Functions
• Abstract Machine
• Resource Manager
OS is split into two layers :
User Space
Kernal Space
Kernal contains all the software that provides
infrastructure to make other software works
User Space – Contains all the software that
user actually interact with.
System calls
When user program requires a service from OS, it makes a system call
• Example: Process makes system call to read data from hard disk
Why?
User process cannot run privileged instructions that access hardware, to prevent
one user from harming another
NOTE : user program does not call system call directly, but uses language library functions
• Example: printf is a function in the C library, which in turn invokes the system call to write to screen
How can applications invoke the OS?
• Special instruction causes a trap / interrupt
• Trap instruction changes PC to point to a predetermined
OS entry point instruction and simultaneously sets the
mode bit
• application calls a library procedure that includes the
appropriate trap instruction
• fetch/decode/execute cycle begins at a pre-specified OS entry
point called a system call
• CPU is now running in privileged mode
• Traps, like interrupts, are hardware events, but they are
caused by the executing program rather than a device
external to the CPU
26
Transition from user to kernel mode
Mode bit: Provided by hardware for dual-mode operation
User mode: Executing privileged instructions will automatically trap to the operating system
kernel mode: Full access to the system is enabled
Processing
At boot time: System is automatically in kernel mode
During System call: Mode automatically changes kernel mode
After responding to system call: Restore application environment, set mode to user, and reschedule the
application
https://www.cse.iitb.ac.in/~mythili/os/iitb_slides/os-intro.pdf
Address space of a process
https://www.cse.iitb.ac.in/~mythili/os/
PC Hardware
X86 Architecture
• x86 is a widely used computer architecture for central processing units (CPUs).
• It has become the dominant architecture for personal computers and servers.
• The name "x86" is derived from the 8086, an early processor released by Intel®.
• x86 CPUs use a complex instruction set computer (CISC) design, allowing them to
execute multiple instructions in a single cycle.
• Over the years, the x86 architecture has undergone significant advancements and
improvements, making it highly compatible and capable of running a vast array of software
applications, contributing to its widespread adoption in the computing industry.
x86 processors
• Intel's processors like the Pentium, Core™ i3/i5/i7/i9, and AMD's
processors like Ryzen™ and Athlon are some of the most well-known
x86 central processing units (CPUs).
x86-64, also known as x64 or AMD64, is an extension of the x86
architecture.
It introduced 64-bit support, allowing the central processing unit
(CPU) to handle larger amounts of memory and process data more
efficiently.
Traditional x86 is 32-bit.
Program to process
Beyond the program memory map
Operating system Structure
• An Operating System (OS) structure defines how its components are
organized and interact to manage hardware and software resources
efficiently
• Components of an OS :
• Kernel , System Calls , Memory Management, Process Management , File
System, Device Drivers , User Interface
Monolithic Structure
• The entire operating system runs as a single
program in kernel mode.
• The operating system is written as a collection of
procedures, linked together into a single large
executable binary program.
• Each procedure in the system is free to call any
other one.
• Being able to call any procedure you want is very
efficient, but having thousands of procedures that
can call each other without restriction may also lead
to a system that is unwieldy and difficult to
understand.
• Also, a crash in any of these procedures will take
down the entire operating system
• The operating system is written as a
collection of procedures each can call any
of the other ones whenever it needs to.
• The entire operating system executes with
maximum privileges.
Virtualisation
Conventional System Architecture : The three major components (hardware, operating systems,
application programs) are largely decoupled (from a development point of view). But, still they work
together only in the proper combinations.
Application software compiled for a particular ISA will not run on hardware that implements a different
ISA. For e.g., Windows application binaries will not run on a Power PC (Mac) processor.
https://www.jsums.edu/nmeghanathan/files/2015/05/CSC439-Sp2013-4-Virtualization.pdf
Virtualization
Virtualization is a technology that facilitates running more
than one operating systems side by-side just on the same
processing hardware.
• Virtualization allows processing that would have been
achieved on multiple computers to run on just one
powerful multi-core processor.
Client Server Model
Two classes of processes
Servers, each of which provides some service, and the clients, which use
these services.
Communication between clients and servers is often by message passing
Operating System Components
Simple Batch Systems
• Early computers were very expensive
• important to maximize processor utilization
• Monitor
• user no longer has direct access to processor
• job is submitted to computer operator who batches
them together and places them on an input device
• program branches back to the monitor when finished
History: Batch Processing
Figure 10.2 In early systems, human operators would organize jobs into batches 10-79
Batch Processing
Batch Processing (Contd…):
• Common output devices were line printers, tape drives, and card punches.
• Users did not interact directly with the computer systems, but he prepared a job
(comprising of the program, the data, & some control information).
OS
User
program
area
• The goal of Multiprogramming is
• Exploit the concurrency operation of I/O and CPU to improve the
throughput.
• New features :
Memory management - to have several jobs ready to run, they must be
kept in main memory
Job scheduling - the processor must decide which program to run.
Multiprocessing operating system
Multi Processing Operating refers to the use of two more central processing units (CPU) within
a single computer system. These multiple CPUs are in close communication sharing the
computer bus. memory and other peripheral devices.
1) ONE IS CONSIDERED AS MASTER OTHERS ARE SLAVES
2) MASTER CPU DECIDES WHICH CPU WILL PERFORM
WHICH TASK OR MASTER EXECUTES SYSTEM PROGRAMS
AND SLAVES ARE USED FOR APPLICATION PROGRAMS
3) ONE PROCESSOR INTERACTS WITH I/O DEVICES AND
OTHERS ARE USED FOR INCREASING THE PROCESSING
POWER
Advantages of multiprocessing
l) INCREASED THROUGHPUT
Parallel processing
Multitasking operating system( Time sharing Operating System
Multitasking is an operating which allows user to perform
more than one computer task (program, process, thread)
at a time.
PERIOD OF TIME FOR WHICH A
PROCESS IS ALLOWED TO RUN
CPU TIME LINE
Distributed Operating system
Clustered operating system
https://www.youtube.com/watch?v=E8WIIK0mxE8
1. Which of the following is abstracted by operating system?
o Processor
o Memory
o Network Cards
o All of the above
• 2. Which one of the following is false ?
Multiprogramming will not cause starvation.
Time sharing improves performance.
Scheduler should able to prioritize some applications.
Kernel runs in a protected mode.
3. Match the following
Instructions a. Heap section
Global and Static Data b. Stack section
Function call invocation c. Data section
Dynamic allocation d.Text section
1-b, 2-a, 3-d, 4-c
1-d, 2-c, 3-a, 4-b
1-c, 2-d, 3-b, 4-a
1-d, 2-c, 3-b, 4-a
4. Name the operating systems most suited for wireless
sensor nodes.
Linux
Windows
Contiki OS
Mac OS
5.State True or False.
To extend the IO address range, we use the low memory
region of the RAM as Memory mapped IO.
True
False
6.fopen() system call switches from _____________ space
7.What is a batch operating system?
1. Multiple individual tasks
2. Similar types of tasks are grouped together
3. Tasks operating at different systems
4. All of the above
Which of the following is typically a part of the operating system but not the kernel?
• Graphical User Interface
• Network Management
• Device Driver Management
• Compiler
• Utilities such as ls, chmod and chown
Q5. Which one of the following is false ?
Monolithic Kernel has direct communication with all the
modules.
Monolithic Kernel is faster than microkernel.
Microkernel is faster than monolithic kernels
Monolithic Kernel is more crashable compared to microkernel.
Answer: Microkernel is faster than monolithic kernels
Q6. State True or False?
Resource abstraction and hardware management are important uses of an OS.
True
False
Answer: True
Q7. Which one of the following is false ?
Multiprogramming will not cause starvation.
Time sharing improves performance.
Scheduler should able to prioritize some applications.
Kernel runs in a protected mode.
Example
There are three jobs running in a multi-programming system with the following
requirements:
Job 1: Requires disk after every 2 min (device service time including wait and access = 2
min). Total processing time = 6 min.
Job 2: Requires printer after every 5 min (device service time including wait and access = 2
min). Total processing time = 7 min.
Job 3: Requires disk after every 3 min (device service time including wait and access = 2
min). Total processing time = 5 min.
Prepare a timing chart showing the CPU and I/O activities of the jobs. Compute the total time
for execution using mono-programming and multi-programming and then compare the
results.