0% found this document useful (0 votes)
14 views15 pages

UNIT 1 Part 5 User Interface and System Calls

Uploaded by

Darmoni Laishram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views15 pages

UNIT 1 Part 5 User Interface and System Calls

Uploaded by

Darmoni Laishram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

UNIT 1

Introduction and
Operating System Structures
Part 5 User and Operating system Interface & System Calls

MCA 3 Semester
rd

Laishram Darmoni
Project Associate
NIELIT IMPHAL
Operating System Structure

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 2


User Operating System Interface
User interface
The OS provides a user interface (UI), an environment for the user to interact with the machine.

There are two fundamental approaches for


users to interface with the operating system:
1. Provides a Command-Line Interface(CLI)
or Command Interpreter that allows
users to directly enter commands that
are to be performed by the operating
system
2. Allows the user to interface with the
operating system via a Graphical User
Interface or GUI

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 3


Command Line Interpreter
• Some operating systems include the command interpreter in the kernel
• Others, such as Windows XP and UNIX, treat the command interpreter as special program.

• On systems with multiple command


interpreters to choose from, the
interpreters are known as shells.
• Example
• Bourne Shell
• C Shell
• Bourne-again Shell (BASH)
• Korn Shell etc.

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 4


Graphical User Interface (GUI)

The OS on most computers


and smartphones provides an
environment with tiles, icons
and/or menus. This type of
interface is called the graphical
user interface (GUI) because the
user interacts with images
through a mouse, keyboard or
touchscreen.

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 5


Touchscreen

• Touchscreen devices require new interfaces


• Mouse not possible or not desired
• Actions and selection based on gestures
• Virtual keyboard for text entry
• Voice commands.

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 6


Difference Between GUI and CLI
Terms GUI CLI
Interaction User interacts with computer using Graphics User interacts with computer using commands.
Navigation Navigation is easy. Navigation is difficult.
Peripherals used Keyboard, mouse or any other pointing device. Only keyboard.
Precision GUI has low precision. CLI has high precision.
Speed GUI is of low speed. CLI is of high speed.
Usage Usage is easy. Usage is difficult, requires expertise.
Memory requirement High memory requirement. Low memory requirement.
Flexibility Highly flexible user interface. Little flexible user interface.
Customize GUI is highly customizable. CLI appearance is not easily changeable.
Typing Check Handles type errors and correct them. CLI don't handles type errors.

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 7


System Calls

System call is the special function that is used by the process to request
action from the operating system which cannot be carried out by normal
function.

When the process is being run, if the process requires certain actions which
need to be carried out by Operating System, the process has to go call the
function which can interact with the kernel to complete the actions. This
special type of function call is known as System Calls in OS.
System calls provide the interface so that the process can
communicate with the Operating System.

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 8


How System Calls Works?
In our computer system, we have two modes available.
1. User Mode: In this mode, execution is done on behalf of the user.
2. Monitor/Kernel-Mode: In this mode, execution is done on behalf of OS.

• So when the process is under execution process executes


under user mode, but when the process requires some OS
resources to complete the task, the process makes a system
call.
• System call is executed in kernel mode on a priority
basis.
• On completion of the system call, the control is passed to
process in user mode.
• The process continues the execution in user mode.

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 9


Types of System Calls
Types of System Calls
There are mainly 5 types of system calls available.

1. Process Control: It handles the system calls for process creation,


deletion, etc. Examples for process control system calls
are: Load, Execute, Abort, Wait Signal events for process.
2. File Management: File manipulation events like Creating, Deleting, Reading
Writing etc. are being classified under file management system calls.
3. Device Management: Device Management system calls are being used
to request the device, release the device, logically attach and detach the
device.
4. Information Maintenance: This type of system call is used to maintain the
information about the system like time and date.
5. Communications: In order to have interprocess communications like send
or receive the message, create or delete the communication connections,
to transfer status information etc. communication system calls are used.

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 10


Examples of Windows and Unix System Calls
Types of System Calls Windows Linux
CreateProcess() fork()
Process Control ExitProcess() exit()
WaitForSingleObject() wait()
CreateFile() open()
ReadFile() read()
File Management
WriteFile() write()
CloseHandle() close()
SetConsoleMode() ioctl()
Device Management ReadConsole() read()
WriteConsole() write()
GetCurrentProcessID() getpid()
Information Maintenance SetTimer() alarm()
Sleep() sleep()
CreatePipe() pipe()
Communication CreateFileMapping() shmget()
MapViewOfFile() mmap()
28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 11
Application Programming Interface (API)
• An API is a set of functions provided by an operating system or other The interface to the services provided by the OS has two
system software. parts:
• An application program calls the functions to request the services. 1. Higher language interface – a part of a system library
• An API clearly defines how to call functions and what the results are. • Executes in user mode
• Implemented to accept a standard procedure call
• Traps to the Part 2
2. Kernel part
• Executes in system mode
• Implements the system service
• May cause blocking the caller (forcing it to wait)
• After completion returns back to user (report the
success or failure of the 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),
• Java API for the Java virtual machine (JVM)
28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 12
System Call Parameter Passing
It is not possible to simply place system call parameters onto the process’ stack as this will not be readily available to the kernel.

There are three main methods to pass the


parameters required for a system call:
1. Pass the parameters in registers (this may
prove insufficient when there are more
parameters than registers).
2. Store the parameters in a block, or table, in
memory, and pass the address of block as a
parameter in a register. This approach is used
by Linux and Solaris.
3. Push the parameters onto a stack; to be popped
off by the OS. Block and stack methods do not
limit the number or length of parameters
passed.
Parameter Passing via Table

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 13


Read() System call
read() system call of file management

• As we can see in the diagram, initially, the process pushes the parameter onto
the stack.
• After that, the read routine from the library is called, which puts the system call
code (unique code for each system call is assigned) into the register.
• Trap instruction is used which causes the transfer of control from user mode to
kernel mode.
• Kernel reads the system call code present in the register and finds out that the
system call is read, so the system call handler executes the read system call.
• After the execution of the read system call, the transfer is given back to the
user mode.
• The library routine (Library routine is nothing but the line of codes that forms
the library and the functions in that can be called by the process so that we
don't need to write the function every time. Eg. max function) in user mode
returns the output to the process which called it.
• On receiving the output, the process continues to execute the next instruction.

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 14


Standard C Library Example

C program invoking printf() library call,


which calls write() system call

28-10-2022 NATIONAL INSTITUTE OF ELECTRONICS AND INFORMATION TECHNOLOGY, IMPHAL 15

You might also like