OS UNIT 1 Introduction to OS
OS UNIT 1 Introduction to OS
UNIT 1
Introduction to Operating
System
By:
Amandeep
Kaur
Topics
Introduction to OS
Supervisor and User Mode
OS Structure
Functions of OS
System Calls
Evolution & Types of OS
OS (Operating System) ?
OS?
It is System Software &
It works as an interface between user and hardware.
For Example: Window (all versions), Linux ( Kali, CentOS, RedHat etc.)
Is it possible to work on system without OS?
a) Yes
b) No
Q. What is an Operating System?
a) interface between the hardware and application programs
b) collection of programs that manages hardware resources
c) system service provider to the application programs
d) all of the mentioned
Ans. d
d) all of the mentioned
Because An Operating System acts as an intermediary between user/user applications/application
programs and hardware. It is a program that manages hardware resources. It provides services to
application programs.
Why OS?
Convenience to the user (due to System Calls i.e. Open, Close, Read,
Write etc.)
Throughput (Linux) i.e. No. of tasks executed per unit time.
Supervisor (Kernel) Mode (#) VS User
Mode ($)
Q. What of the following is not the type of OS?
a. Windows
b. RHEL
c. Oracle
d. Android
Ans. C
c. Oracle
OS Structure
OS Structure
Hardware is the storage space like hard disk, floppy disk, CD drive etc.
Kernel is the heart of the OS where we can find many system call.
System call i.e. which consist of codes for commands.
It handles many functions like managing files, creating file directories, managing
memory etc.
OS Structure
Shell is interface between kernel and application.
i.e. It is a place where we write program and execute them.
Syntaxes are checked and errors are rectified in this shell.
Application are nothing but are things which we see or we use, are applications.
Q.In the layered structure of an operating system, which layer is responsible for
handling hardware-level operations, such as CPU scheduling and device
management?
A. Application Layer
B. Shell Layer
C. Hardware Layer
D. User Interface Layer
Ans. C
C. Hardware Layer
Q. What is the main function of the CLI
(Command Line interpreter) or Shell?
a) To provide the interface between the API and application program
b) To handle the files in the OS
c) To get and execute the next user-specified command
d) None of the mentioned
Ans. C
The main function of a command interpreter is to get and execute the next user-specified
command. Command Interpreter checks for valid command and then runs that command else it
will throw an error.
Q. What is System Call?
System Calls
System call i.e. which consist of codes for commands using C language or predefined functions
that OS directly invoke or It is a way for a user program to interface with the OS.
The program requests several services, and the OS responds by invoking a series of system calls to
satisfy the request. The kernel system can only be accessed using system calls. System calls are
required for any programs that use resources.
Example
Open a file or open folder (directory).
In case of system, read() and write()
K/B for read data : read()
Monitor for Write data : write()
How System Calls Works?
Step 1) The processes
executed in the user
mode till the time a
system call interrupts it.
Step 2) After that, the
system call is executed
in the kernel-mode on a
priority basis.
Step 3) Once system
call execution is over,
control returns to the
user mode.,
Step 4) The execution of
user processes resumed
in Kernel Mode.
Why System Calls?
Reading and writing from files demand system calls.
If a file system wants to create or delete files, system calls are required.
System calls are used for the creation and management of new processes.
Network connections need system calls for sending and receiving packets.
Access to hardware devices like scanner, printer, need a system call.
Types of System Calls
Types of System Calls
Process Control
Process control is the system call that is used to direct the processes. It include creating,
load, abort, end, execute, terminate the process, etc.
File Management
File management is a system call that is used to handle the files. It include creating files,
delete files, open, close, read, write, etc.
Device Management
Device management is a system call that is used to deal with devices. It include read
device, write device, get device attributes, release device, etc.
Types of System Calls
Information Maintenance
It is used to maintain information. For example: getting system data, set time or date,
get time or date, set system data, etc.
Communication
It is used for communication. For example: create, delete communication connections,
send, receive messages, etc.
Some Important System calls in Windows and
Unix OS
Few methods in brief
open()
The open() system call allows you to access a file on a file system. It allocates resources
to the file and provides a handle that the process may refer to. Many processes can open a
file at once or by a single process only. It's all based on the file system and structure.
close()
It is used to end file system access. When this system call is invoked, it signifies that the
program no longer requires the file, and the buffers are flushed, the file information is
altered, and the file resources are de-allocated as a result.
Few methods in brief
read(): It is used to obtain data from a file on the file system. It accepts three arguments in
general:
1. A file descriptor.
2. A buffer to store read data.
3. The number of bytes to read from the file.
The file descriptor of the file to be read could be used to identify it and open it
using open() before reading.
Few methods in brief
write()
It is used to write data from a user buffer to a device like a file. This
system call is one way for a program to generate data. It takes three
arguments in general:
1. A file descriptor.
2. A pointer to the buffer in which data is saved.
3. The number of bytes to be written from the buffer.
Few methods in brief
fork()
It is one of the most common ways to create processes in operating
systems. Also, clone (copy) of that process.
Formulas to find:
Total no. of Process = 2n
Total No. of Child Process = 2n - 1
Few methods in brief
Wait()
In some systems, a process may have to wait for another process to complete its execution before
proceeding. When a parent process makes a child process, the parent process execution is
suspended until the child process is finished. The wait() system call is used to suspend the parent
process. Once the child process has completed its execution, control is returned to the parent
process.
Few methods in brief
exec(): When an executable file replaces an earlier executable file in an already executing process,
this system function is invoked. As a new process is not built, the old process identification stays, but
the new process replaces data, stack, data, head, etc.
exit():It is used to end program execution. This call indicates that the thread execution is complete,
which is especially useful in multi-threaded environments. The OS reclaims resources spent by the
process following the use of the exit() system function.
Q. Which of the following is NOT a type of
system call in an operating system?
A) Process control
B) File management
C) Memory allocation
D) User interface rendering
Ans.D
D) User interface rendering
User interface rendering is typically handled by higher-level libraries or frameworks, not by
system calls. System calls are used for low-level operations like process control, file
management, and memory management.
Q. Which system call is used to create process?
a) Open()
b) Write()
c) Fork()
d) Sleep()
Ans. c
Fork(): it is used to create new process and there is formula to find out the number of child
process which is 2 -1
n
Main Functions of OS
Resource Management (H/W)
Process Management (CPU Scheduling)
Storage Management (HD)
Memory Management (RAM)
Security (Password)
Evolution of OS
Types of OS
Simple Batch System
Multi-Programming & Multi-Processing System
Multi-Tasking
Parallel
Distributed &
Real-Time Operating System (RTOS) etc.
Batch System
It does not interact with the computer directly. There is an operator which takes similar jobs having
the same requirement and groups them into batches. It is the responsibility of the operator to sort
jobs with similar needs.
In this system, Punch cards/Paper Cards/Magnetic Tape used
Problem: idleness(CPU)
Solution: Multi-Programming concept
Multi-Programming,Multi-Processing & Multi-
Tasking
Parallel V/S Distributed System
Parallel V/S Distributed System