Ch1 Introduction
Ch1 Introduction
Operating systems
Course Objective:
• To impart knowledge of Process, Memory and File management of
operating system from user and design perspectives.
Course Outcomes (COs): After learning the course students will be able to
1. Understand basic functions of operating system, system call and design
structures
2. Explore the process management policies, process synchronization, Dead
lock detection and prevention mechanisms used in different operating systems
3. Analyze scheduling algorithms used in different operating systems
4. Compare different memory management schemes and page replacement
algorithms.
5. Analyze file systems from user and design perspective.
6. Understand role of device driver in I/O management.
Examination
Operating systems
• List of References:
• 1. Andrew S. Tanenbaum, “Modern Operating
Systems”, Prentice Hall International
• 2. Silberschatz and Galvin, “Operating System
Concepts”, John Willey and Sons
• 3. William Stallings,“Operating Systems”
Prentice Hall of India
• 4. D.M.Dhamdhere, “Operating Systems”, Tata
McGraw Hill
Why os is required?
Modern computer system consists of one or more
processors, some main memory, disks, keyboard, a display,
a network interfaces and other I/O devices.
Writing programs that keep track of all these components
and use them correctly and optimally is an difficult job.
c
user1 user2 user3
a l
t s p p
r r Desktop
Director
o o
y
g g s
r r t File
m m a
Directory : As a way of
1 2 r
grouping files together
t
File system
• Every file can be specified by giving its path name from the top
of directory hierarchy, the root directory
• Two types of path : absolute and relative
• Every process has current directory
• System call related to files : open,read,write, dup, lseek, fcntl,…
• Mounting files : attach other file system with root file system
• Special files : devices are treated as files, block and character,
pipe
• Security : nine bit protection code
• For directory x indicates search permission
History of operating systems
Multiprogramming OS
Decision has to be made as to where to place the jobs
in the main memory. Hence memory management was
added as a functionality of the operating system. I/O
devices also have to be allocated to processes. Hence
I/O management was included as a functionality to the
operating system.
Multiprogrammed systems provide an environment in which the
various system resources (for example, CPU, memory, and
peripheral devices) are utilized effectively, but they do not provide
for user interaction with the computer system.
Real-time systems
main()
{
char m[20]=“hello\n”;
asm(“mov $4,%eax”);
asm(“mov $1,”ebx”);
asm(“mov $m,”%ecx”);
asm(“mov $7,%edx”);
asm(“int $128”);
POSIX
• POSIX has about 100 procedure calls
• Mapping of POSIX procedure calls onto
system calls is not one to one. However most
of the POSIX procedures do invoke system
calls
The POSIX standard specifies a number
of procedures that a conformant system must
supply, but it does not specify whether they are
system calls, library calls, or something else.
If a procedure can be carried out without
invoking a system call (i.e., without trapping to
the kernel), it will
usually be done in user space for reasons of
performance.
However, most of the POSIX procedures do
invoke system calls, usually with one procedure
mapping directly onto one system call.
In a few cases, especially where several required procedures
are only minor variations of one another, one system call
handles more than one library call
#define TRUE 1
while (TRUE) { /* repeat forever */
type prompt( ); /* display prompt on the screen */
read command(command, parameters); /* read input from terminal */
if (for k( ) != 0){ /* fork off child process */
/* Parent code. */
waitpid( parameters); /* wait for child to exit */
} else {
/* Child code. */
execve(command, parameters, 0); /* execute command */
}
}
Figure 1-19. A stripped-down shell. Throughout this book,
TRUE is assumed to
be defined as 1.
Win32 API
• Windows and UNIX differ in a fundamental way in their respective
programming models.
• A UNIX program consists of code that does something or other, making system
calls to have certain services performed
windows program is normally event driven Main program waits for some event
to happen, then calls a procedure to handle it.
• Microsoft has defined a set of procedures called the Win32 API (Application
Programming Interface) that programmers are expected to use to get
operating system services
• By decoupling the API interface from the actual system calls, Microsoft retains
the ability to change the actual system calls in time (even from release to
release) without invalidating existing programs.
Win32 has a huge number of calls for managing the GUI
Windows does not have a process hierarchy so there is no concept of a parent and
child process
Win32 interface does not have links to files, mounted file systems, security or
signals
Win32 API calls & corresponding
Unix calls
Design structures
Monolithic systems
• In the monolithic approach 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.
• Os is written as a collection of procedures each of which can call any of the
other ones whenever it needs to
• OS occupy single address space. To construct the actual object program of
the OS, one first compiles all the individual procedures or files containing
the procedures and then binds them all together into a single object file using
the linker
• Advantage : efficient
• Disadvantage : any part of OS fail, entire OS fail ,difficult to modify
because lot of interfacing among modules, no protection
• e.g. Unix, Linux
• Little structure exists : The services (system
calls) provided by the operating system are
requested by putting the parameters in a well-
defined place (e.g., on the stack) and then
executing a trap instruction. This instruction
switches the machine from user mode to
kernel mode and transfers control to the
operating system
This organization suggests a basic structure for the
operating system:
1. A main program that invokes the requested
service procedure.
2. A set of service procedures that carry out the
system calls.
3. A set of utility procedures that help the service
procedures.
Design structures
Buffer
cache
Windows NT
Hybrid Kernel
Layered, Microkernel
Executive: object
management, IPC Virtual
memory management
Microkernel: process
synchronization, scheduling
Questions