0% found this document useful (0 votes)
13 views22 pages

Unit1 CSE316 System Calls 24252

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)
13 views22 pages

Unit1 CSE316 System Calls 24252

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/ 22

Chapter 1: Interrupt/System Calls

Interrupt
● An interrupt:
● A signal from a device attached to a computer OR
● From a program within the computer
That causes the main program that operates the computer (the operating
system) to stop and figure out what to do next.

● Interrupts can be of the following type:

● Generated by Hardware (Hardware Interrupt)

● Generated by Software (Software Interrupt)


Hardware Interrupt
1. Hardware interrupts are used by devices to communicate that they
require attention from the operating system.
2. Hardware interrupts by sending a signal to CPU via a system bus.
3. An interrupt number references hardware interrupts.
4. These numbers are mapped with hardware that created the interrupt.
5. Enabling the system to monitor/understand:
which device created the interrupt and when it occurred.
Software Interrupt/ Trap
• Interrupt generated by executing a instruction.
• Software interrupts by a special operation called a
System Call or Monitor Call.
Exp: 1. cout in C++ is a kind of interrupt because it would
make a system to print something.
2. division by zero
I/O Interrupt
• Once the I/O is started, 2 kind of interrupts may arise:
• Synchronous interrupt (I/O): The control is transferred
to the user process when I/O completes.
• Asynchronous interrupt (I/O): Returns control to user
process without waiting for I/O to complete.
(a) Synchronous (b) Asynchronous
System Calls
• Allow user-level processes to request services of the operating
system.
• It provides a way in which program talks to the operating system.

Why system calls are required?


• It is a request to the operating system to perform some activity.
• It is a call to the kernel in order to execute a specific function that
controls a device or executes a instruction.

• A system call looks like a procedure call


Working of System Call
Example of System Calls
• System call sequence to copy the contents of one
file to another file
API – System Call – OS Relationship
Standard C Library Example
• C program invoking printf() library call, which calls write()
system call
System Call Parameter Passing
Passing Parameters to System Calls:
• Information required for a system call vary according to OS and
call.
• Three general methods used to pass parameters to the OS
1. Pass the parameters in registers
• When parameters are < 6.
2. Parameters stored in a block, or table, in memory, and address of block
passed as a parameter in a register. (6 or more)
• This approach taken by Linux and Solaris
3. Parameters placed, or pushed, onto the stack by the program and popped
off the stack by the operating system.
Types of System Calls
5 Categories
• Process Control ● File Management
– end, abort ● create file, delete file
– load, execute
● open, close file
– create process, terminate
● read, write, reposition
process
– get process attributes, set ● get and set file attributes
process attributes
– wait for time
– wait event, signal event
– allocate and free memory
Types of System Calls (Cont.)
• Device Management ● Communications
– request device, release device
● create, delete
– read, write, reposition communication
– get device attributes, set device connection
attributes ● send, receive messages
– logically attach or detach devices
● transfer status
• Information Maintenance information
– get time or date, set time or date ● attach and detach remote
– get system data, set system data devices
– get and set process, file, or device
attributes
System Call Implementation

HLL provide System Call Interface

Program makes API Call (application


programming interface)

API trapped by RTL (run time library)

RTL places system calls in register

Places parameters in specific


locations and Completes System Call
When a system executes a C program, CPU runs in ____ mode.
a) user
b) kernel
c) supervisory
d) system
When a user initiates to execute a C program, CPU runs in ____ mode.
a) user
b) kernel
c) supervisory
d) system
Which program signal for the occurrence of an event either from
the hardware or the software?
a) Bootstrap program
b) Interrupt
c) Disk Controller
d) CPU
MCQ
What is the objective of multiprogramming?
A Have some process running at all times
B Have multiple programs waiting in a queue ready to run
C To minimize CPU utilization
D None of the mentioned
MCQ
In a multiprogramming environment .....
A the processor executes more than one process at a time
B the programs are developed by more than one person
C more than one process resides in the memory
D a single user can execute many programs at the same time
Practice MCQ:
Link: https://forms.gle/PY2o8vRLKfeUU6qq7

QR Code:
Next Topic!!

You might also like