Basic concepts of OSOS Structures
G.Anuradha
Basic concepts of OS
• Processes• Deadlocks• Memory management• Input/output• Files• Security
Processes
• Process is a program in execution• Associated with each process we have
– Address space (executable program+data+stack)– List of memory locations (with max and min
memory locations)– Registers(stack pointer, program counter,
hardware registers)– Eg: Time Sharing System
Processes Contd.
• Whenever a process is suspended temporarily the current state of the process is stored in a process table.
• Interprocess communication is the Communication between different interrelated process
• When communicating between processes of different computers a alarm signal is send to notify lost messages.
Processes Contd.
• In UNIX processes, every user who logs in has a Unique Identification (UID).
• Every process started has the UID of the person who started it
• A child process has the UID as that of parent• Members of the same group can have Group
Identification(GID)• One UID called Superuser has all the
administrative powers.
Deadlocks
Deadlocks Contd…
• When two or more processes are interacting, they can sometimes get themselves into a stalemate situation they cannot get out of. Such a situation is called a deadlock.
• Processes in a computer can experience an analogous situation in which they cannot make any progress
Memory Management
• Main memory holds the executing program• In simple OS only one executing program
resides in the main memory• In sophisticated OS more than one executing
program can reside in memory• To prevent them from interfering with each
our some protection mechanism has to be provided by the OS
Memory Management Contd…
• Managing the address space of the processes.• The executable program address space is less
than the main memory address space for the program to reside in the memory
• If the program address space is more than main memory address space a concept of virtual memory is used
• Virtual Memory-OS keeps part of address space in memory and part in disk and shuttles between both
Input/Output
• OS has to manage the input output devices like keyboards, monitors, printers….
• Every OS has I/O subsystem for managing the I/O devices
• Some I/O software are device independent but some device drivers are specific to particular I/O devices
Files
• One major function of the OS is to hide the peculiarities of the disks and other I/O devices and present the programmer with a nice, clean abstract model of device-independent files
• System calls are needed – create files– remove files– read files– write files.
Files Contd…
• OS has a concept of directory for grouping files together(UNIX) the path for file CS101 is
/Faculty/Prof.Brown/Courses/CS101.
Files Contd…
• Every file within the directory hierarchy is specified by its path name from the root directory.
• Each process has a current working directory• Before a file can be read or written, it must be
opened, at which time the permissions are checked
• If permitted the system returns a file descriptor else an error code is returned
Special Files
• Special files are provided in order to make I/O devices look like files.
• Two kinds of special files exist– block special files :- used to model devices that
consist of a collection of randomly addressable blocks (disks)
– character special files:-used to model printers, modems, and other devices that accept or output a character stream.
Pipes
•A pipe is a sort of pseudofile that can be used to connect two processes•If processes A and B wish to talk using a pipe, they must set it up in advance.•When process A wants to send data to process B, it writes on the pipe as though it were an output file.•Process B can read the data by reading from the pipe as though it were an input file.
Security• OS has to manage the system security so that files, are
accessible to authorized users.• In UNIX security is provided by 9-bit binary protection
code• The protection code consists of three 3-bit fields
– Owner– Members of the owner’s group– Everyone
• rwxr-x--x – r read– w write– x execute
Shells(exclusive for UNIX)
• OS carries out system calls• Although Shells are not part of OS it makes
use of many OS Features• When user logs in a shell is started • Shell has terminal as standard input and
standard output• It starts out by typing the prompt, a character
such as a dollar sign, which tells the user that the shell is waiting to accept a command
OS-Structure • Simple structure• Layered approach• Microkernels• modules
Simple Structure
• Do not have a well-defined structure• MS-DOS – written to provide the most functionality in
the least space– Not divided into modules– Although MS-DOS has some structure, its interfaces
and levels of functionality are not well separated
MS-DOS Layer Structure(Simple Structure)
initially written to provide the most functionality in the least space
started small and grew beyond its original scope
levels not well separated: programs could access I/O devices directly
excuse: the hardware of that time was limited (no dual user/kernel mode)
Simple Layered Approach(UNIX)
• Enormous functionality crammed into the kernel below the system call interface
• No encapsulation but total visibility across system
• Made of thick monolithic layers
More functionality combined into one level system call interface to the kernel
Fully Layered Approach• The operating system is divided into a
number of layers (levels), each built on top of lower layers.
• The bottom layer (layer 0), is the hardware; The highest (layer N) is the user interface.
• With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers
• THE system (by Dijkstra), MULTICS, GLUnix, VAX/VMS
Solaris Modular Approach
Advantages :- 1.More flexible than a layered system2.More efficient than the micro kernel approach because there is no message passing
Mac OS X Structure
•Uses a hybrid structure•Mach provides
•Memory management•Remote Procedure Calls•Interprocess communication facilities•Thread Scheduling
•BSD(Berkeley Software Distribution) provides
•Command line interface•Support for networking and file systems•Implementation of POSIX API
Types of OS:
Operating System can also be classified as,-
• Single User Systems
• Multi User Systems
Single User Systems:
• Provides a platform for only one user at a time.
• They are popularly associated with Desk Top operating system which run on standalone systems where no user accounts are required.
• Example: DOS
Multi-User Systems:
• Provides regulated access for a number of users by maintaining a database of known users.
• Refers to computer systems that support two or more simultaneous users.
• Another term for multi-user is time sharing.
• Ex: All mainframes and are multi-user systems.• Example: Unix
University Questions• What are system calls and its types• Difference between monolithic and micro kernel• What is kernel and how do u design it?• Short notes on monitor• What is shared memory? Difference between shared memory and
message passing• What are the various system calls for process management• Services provided by OS