Wednesday, October 6, 2010

What is Operating System ?

An operating system is a program designed to run other programs on a computer. It is defined as system software that control and coordinate all the working of computer system. It is considered the backbone of a computer, managing both software and hardware resources. It acts as an intermediary between a user of a computer and the computer hardware.
Operating systems are responsible for everything from the control and allocation of memory to recognizing input from external devices and transmitting output to computer displays.


Operating System is a software that manages computer hardware.
An operating system as the programs that make the hardware useable.
An operating system is the set of programs that controls and coordinates the operation of various Input, Output and Process devices; i.e. a computer
 
Objectives of OS
To hide details of hardware
Examples
Operating systems provide subroutines called device drivers that perform operations on behalf of programs for example, input/output operations.
Files so that programs do not have to deal with disks.
Each application appears to have the entire machine to itself.
OS transforms the computer hardware into multiple virtual computers, each belonging to a different program. E
  
Resource Allocator
To allocate resources to processes so that multiple users share resources fairly, efficiently, safely and securely.
Example
Multiple processes share one processor.
Multiple programs share one physical memory
Multiple users and files share one disk.
 
Provide a pleasant and effective user interface
The user interacts with the operating systems through the user interface.
Common Interfaces are
Command line User Interface (CUI)
Commands that are given to the operating system via command statements that execute
Graphical  User Interfaces (GUI)
User employs a mouse based window and menu system
ऑपरेटिंग सिस्टम एक डिज़ाइन प्रोग्राम है जो कंप्यूटर पर अन्य प्रोग्राम चलाने के लिए बनाया गया है. यह एक सिस्टम सॉफ्टवेयर है जो नियंत्रण और कम्प्यूटर प्रणाली के सभी काम करता है। यह एक कम्प्यूटर की रीढ़ माना जाता है, दोनों सॉफ्टवेयर और हार्डवेयर के संसाधनों का प्रबंधन है. यह एक user और कंप्यूटर हार्डवेयर के बीच एक मध्यस्थ के रूप में कार्य करता है.
ऑपरेटिंग सिस्टम नियंत्रण और स्मृति के बाह्य उपकरणों से इनपुट पहचानने और कंप्यूटर को दर्शाता है उत्पादन प्रसारण के लिए आवंटन से सब कुछ के लिए जिम्मेदार हैं.

Operating System are designed to

1. Convenience: Operating system makes computer more convenient to use.

2. Efficiency: Operating system allows computer resources to be used in the efficient manner.

3. Ability to evolve: Operating system permits efficient development, testing and introduction of new system without interfering with current provided services.

आपरेटिंग सिस्टम design किया गया
1. सुविधा: ऑपरेटिंग सिस्टम कंप्यूटर का उपयोग अधिक सुविधाजनक बनाता है.

2. क्षमता: ऑपरेटिंग सिस्टम कम्प्यूटर संसाधनों का प्रभावी ढंग से प्रयोग की जाने की अनुमति देता है.

3. विकसित करने की योग्यता: ऑपरेटिंग सिस्टम> वर्तमान प्रदान की गई सेवाओं के साथ हस्तक्षेप किए बिना कुशल विकास, परीक्षण और नई प्रणाली का परिचय दे सकते हैं.

EVOLUTION OF OPERATING SYSTEM

Operating system has evolved through various stages of its development like Serial Processing, Batch Processing, Multi Programming and Time Sharing System.

1. Batch Systems: In this system, the user did not interact directly with the computer system. The user prepared a job which consisted of the program, the data and some control information and submitted it to the computer operator. This job is in the form of punch cards. After some time, the output appeared. To speed up processing, operators batched together jobs with similar needs and ran them as a group. In this environment, the CPU is often idle because the speeds of the I/O devices are slower than CPU.
इस प्रणाली में हो, तो user सीधे कंप्यूटर system के साथ संपर्क नहीं किया है. user एक job जो प्रोग्राम, डाटा और कुछ नियंत्रण की जानकारी शामिल है और यह कम्प्यूटर ऑपरेटर को submit किया जाता है . यह job पंच कार्ड के रूप में है. कुछ समय के बाद, output दिखाई देता है . Processing Speed increase करने के लिए , ऑपरेटरों सारे job जो एक सामान है एक समूह (batch) के रूप में execute करते है. इसमे CPU अक्सर idle है, क्योंकि I/ O device, सीपीयू की तुलना में धीमी गति से काम करते है.

2.  Multiprogrammed Systems: A single user cannot keep either CPU or the I/O devices busy all the times. In multiprogrammed system, the operating system keeps several jobs in memory simultaneously. When one program needs I/O, that job is suspended and the other job whose data is ready and in main memory and waiting for CPU is taken up for execution. In this way, multiprogramming, organizes job so that CPU always has one to execute and thus increases CPU utilization.
Multiprogrammed सिस्टम: एक single user CPU को हमेशा व्यस्त नहीं कर सकते. Multiprogrammed प्रणाली में, ऑपरेटिंग सिस्टम memory में कई jobs एक साथ रहते है। जब एक प्रोग्राम मैं I/O की जरुरत होती हे, उस काम को निलंबित कर दिया जाता है और दूसरे काम जिसका डाटा तैयार है और main memory में है और CPU के इंतज़ार कर रही है उसे CPU दे दिया जाता है. इस तरह, multiprogramming, jobs organizes करता है जिसमे हमेशा एक job exeute होता है और सीपीयू उपयोग बढ़ता है।

3. Time Sharing Systems: Time Sharing or Multitasking is an extension of Multiprogramming. In this, CPU executes multiples jobs by switching among them. A time-shared operating system allows many users CPU scheduling and multiprogramming to provide each user with a small potion of time shared computer. Each command in a time shared system tends to be short know as quantum only little CPU time is needed for different process. As the system switches rapidly from one user to the next, each user is given the impression that the entire computer is dedicated to her use even though it is shared among many users process.
Time Sharing operating systems are more complex than multiprogramming operating systems. To ensure orderly execution of process, the system must provide mechanisms for concurrent execution of process , process synchronization and communication.
Time Sharing या Multitasking, multiprogramming का ही विस्तार है. इसमें, सीपीयू jobs में स्विच करके सारे jobs execute करता है।एक बार ऑपरेटिंग सिस्टम साझा कई प्रयोक्ताओं की अनुमति देता है CPU समयबद्धन और समय का एक छोटा सा औषधि कंप्यूटर साझा के साथ एक उपयोगकर्ता प्रदान बहु क्रमादेशन. एक साझा प्रणाली के समय में प्रत्येक आदेश को कम ही थोड़ा CPU समय मात्रा के रूप में जानते अलग प्रक्रिया के लिए जरूरी है जाता है. के रूप में प्रणाली एक उपयोगकर्ता से अगले, प्रत्येक उपयोगकर्ता धारणा है कि पूरे कंप्यूटर उसे इस्तेमाल करने के लिए समर्पित हालांकि यह प्रक्रिया कई प्रयोक्ताओं के बीच साझा किया है दी गई है तेजी से स्विच.
समय साझा ऑपरेटिंग सिस्टम विविध ऑपरेटिंग सिस्टम की तुलना में अधिक जटिल है. प्रक्रिया को व्यवस्थित करने के क्रियान्वयन सुनिश्चित करने के लिए प्रणाली की प्रक्रिया के समवर्ती निष्पादन, प्रक्रिया तुल्यकालन और संचार तंत्र के लिए प्रदान करनी चाहिए.



Types of Operating System


1. Single User OS
–Single-user operating systems have no facilities to distinguish users, but may allow multiple programs to run in tandem
2. Single Tasking OS
–A single-tasking system can only run one program at a time
•Features of Single User and Single Tasking OS
–MS-DOS and Palm OS
–Take up little space on disk
–Run on inexpensive computer

3. Multi Taskin (Time Sharing) OS
   Multiprocessing and Multitasking are used interchangeable BUT
–multiprocessing sometimes implies that more than one CPU is involved.
–The ability to execute more than one task at the same time is called as multitasking.

Multi-tasking operating system allows more than one program to be running in concurrency.


In multitasking, only one CPU is involved, but it switches from one program to another so quickly that it gives the appearance of executing all of the programs at the same time.

This is achieved by time-sharing, dividing the available processor time between multiple processes that are each interrupted repeatedly in time slices.

Examples: Linux, Scolaris, Windows NT, AmigaOS





4. Multi User OS
A multi-user operating system extends the basic concept of multi-tasking with facilities that identify processes and resources belonging to multiple users, and the system permits multiple users to interact with the system at the same time.

Gives illusion that each user has his own machine.

Each user has a unique session.

5. Distributed System



A distributed operating system manages a group of distinct computers and makes them appear to be a single computer.

A distributed computer system is a collection of autonomous computer systems capable of communication and cooperation via their hardware and software interconnections.

Advantages of distributed System
Resources Sharing
Computation speed up
 load balancing
Scalability
Reliability
Fail-Safe

6. Real time systems
Real time systems are used in time critical environments where data must be processed extremely quickly because the output influences immediate decisions.

Real time systems are used for space flights, airport traffic control, scientific experiments industrial processes, sophisticated medical equipments, telephone switching etc

Each process is assigned a certain level of priority that corresponds to the relative importance of the event that it services.

The processor is normally allocated to the highest-priority process among those that are ready to execute.

7. Embedded Systems
OS embed on the System itself
Fast, Application specific
Examples Processor in modern washing machines, Cell phones, Control systems etc…


Booting Process

Booting may be defined as the process of loading the Operating System onto the RAM

Once the computer system is turned on,the following are the steps that a typical boot sequence involves.

  • The BIOS performs Power on Self Test (POST) that checks to see whether the devices in the system are in perfect order. 

  • After the BIOS is done with the pre boot activities, it searches for the Master Boot Record in the first physical sector of the bootable disk. When it finds one, it implies that it is the bootable partition, and, the Operating System loader, also called the boot strap loader is loaded from that partition onto the memory. A boot strap loader is a special program that is present in the boot sector of the bootable drive.

  • MS DOS Operating system comprises of the following files
  1. IO.Sys
  2. MSDOS.Sys
  3. Command.Com
  4. Config.Sys
  5. Autoexec.bat
Note: The first three files are mandatory while the rest two are optional. Further, the first three files should be present in the bootable drive of the disk
  • The boot strap loader first loads the IO.SYS file. The IO.Sys file as the name suggests, is responsible for Input Output in the DOS environment. 

  • The next file that is loaded is the MSDOS.SYS which is the core of the DOS operating system. The MSDOS.Sys file is  responsible for Memory management and Processor Management in the DOS environment. 

  • The MSDOS.SYS file now searches to find the name of the command interpreter in the CONFIG.SYS file and when it finds one, it loads the same onto the memory. 

  • If no command interpreter is specified in the CONFIG.SYS file, the COMMAND.COM file is loaded as it is the default command interpreter of DOS Operating system.

  • The last file to be loaded and executed is the AUTOEXEC.BAT file that contains a sequence of DOS commands.

  • Now, the prompt is displayed and you can see the drive letter of the bootable drive displayed on your screen indicative of the fact that the Operating System has been loaded successfully from that drive.

Command Interpretation

Command Interpreter is the interface between the user and the operating system. Many commands are given to the operating system by control statements. when a new job is started, or when user logs on to the system, a program that reads and interprets control statements is executed automatically. This program is called interpreter or command interpreter. It is also know as shell. The function is to get the next command and execute it.
The Command Interpreter must be user friendly. One style of user friendly interface is the mouse based window in Microsoft Windows. The mouse is moved to position the mouse pointer on images known as icon. Depending upon the position of mouse pointer, clicking a button can open program, select a file or folder or pull down menu that contains commands.

IO.SYS

IO.SYS is an essential part of MS-DOS. It contains the default MS-DOS device drivers  and the DOS initialization program.
In the PC booting process, the first sector of the boot disk is loaded into memory and executed. If this is the DOS boot sector, it loads the first three sectors of IO.SYS into memory and transfers control to it. IO.SYS then:
  1. Loads the rest of itself into memory.
  2. Initializes each default device driver in turn.
  3. Loads the DOS kernel and calls its initialization routine. The kernel is stored in MSDOS.SYS with MS-DOS and in IO.SYS with Windows 9x.
  4. Processes the MSDOS.SYS file with Windows 9x.
  5. Processes the CONFIG.SYS file.
  6. Loads command.com
  7. Displays the bootsplash in Windows 9x.

MSDOS.SYS

MSDOS.SYS an important system file on MS-DOS and Windows 9x systems. It is run after IO.SYS. In MS-DOS, it contains the core operating system code, the kernel. The Windows Setup program creates a file called Msdos.sys in the root folder and sets the file with the Read-Only, System, and Hidden attributes. Unlike the Msdos.sys file in MS-DOS, this file is a text file. It contains a [Paths] section that lists the locations for other Windows files (such as the registry) and an [Options] section that you can use to personalize the boot process.

By default the file is located in the root directory of the bootable drive/partition (normally C:\) and has the hidden, read-only and system file attributes set.

CONFIG.SYS

CONFIG.SYS is the primary configuration file for the DOS and OS/2 operating systems. It is a special file that contains setup or configuration instructions for the computer system.

The commands in this file configure DOS for use with devices and applications in the system. The commands also set up the memory managers in the system. After processing the CONFIG.SYS file, DOS proceeds to load and execute the command shell specified in the COMMAND.COM. The command shell in turn is responsible for processing the AUTOEXEC.BAT file.

In DOS, CONFIG.SYS is located in the root directory of the drive from which DOS was booted.


CONFIG.SYS डॉस और ओएस ऑपरेटिंग सिस्टम के लिए प्राथमिक configuration फाइल है. यह एक विशेष फ़ाइल है जिसमे कम्प्यूटर के सेटअप या configuration details  शामिल है.

 उपकरणों और प्रणाली में अनुप्रयोगों के साथ प्रयोग के लिए इस फ़ाइल को विन्यस्त डॉस में हासिल है. भी व्यवस्था में सेट कमांड स्मृति प्रबंधक. बाद CONFIG.SYS फ़ाइल प्रसंस्करण, डॉस आय और लोड करने के लिए आदेश COMMAND.COM में विनिर्दिष्ट खोल निष्पादित अगर ऐसी कोई रेखा है. बदले में कमांड खोल AUTOEXEC.BAT फ़ाइल प्रोसेसिंग के लिए जिम्मेदार है.

इस फाइल के कोम्मोंड्स डॉस को configure करते है दूसरी devices and applications को इस्तेमाल करने के लिए. इसके कमांड्स memory managers को भी सेट उप करते है. की प्रोसेसिंग के बाद डॉस लोड और execute करता है command shell जो   COMMAND.कॉम में स्टोर है. command shell AUTOEXEC.BAT file. की प्रोसेसिंग के लिए जिम्मेवार होता है.

डॉस में CONFIG.SYS root directory में स्टोर होती है जहा से डॉस लोड होता है.

AUTOEXEC.BAT

AUTOEXEC.BAT is a system file found originally on the MS-DOS operating system. It is a plain-text batch file that is located in the root directory of the boot device. The name of the file stands for "automatic execution", which describes its function in automatically executing commands on system startup.

AUTOEXEC.BAT is most often used to set environment variables such as keyboard, soundcard, printer, and temporary file locations. It is also used to initiate low level system utilities, such as the following:
  • Virus scanners

  • Mouse drivers
  • Keyboard drivers
  • CD drivers
  • Miscellaneous other drivers

For example:  Suppose if user want to modify system date , to set the path of the your directory, then batch file AUTOEXEC.BAT  is created as

C:\> EDIT AUTOEXEC.BAT

Type following commands in DOS Editor
ECHO
CLS
DATE
PATH=D:\AMRIT;

 AUTOEXEC.BAT डॉस ऑपरेटिंग सिस्टम system file है.  यह एक plain-text batch file जो  boot device की है कि root directory में स्टोर होती है. Stands for "automatic execution", जो स्टार्टअप पर स्वचालित रूप से क्रियान्वित होती है.

AUTOEXEC.BAT environment variable जैसे कुंजीपटल, soundcard, प्रिंटर को  सेट किया जाता है, और अस्थायी फ़ाइल स्थानों. यह भी इस तरह के निम्नलिखित के रूप में निम्न स्तर की प्रणाली उपयोगिताओं, आरंभ किया जाता है:

     * स्कैनर वायरस
     *  माउस ड्राइवर
     * कुंजीपटल ड्राइवर
     * सीडी चालकों
     * विविध अन्य ड्राइवरों

उदाहरण के लिए: मान लीजिए, यदि user तारीख बदलना चाहते हैं, अपने वोर्किंग डायरेक्टरी का पथ सेट करना है  तो बैच फ़ाइल AUTOEXEC.BAT के रूप में बनाया जाता है

C:\> EDIT AUTOEXEC.BAT

Type following commands in DOS Editor
ECHO
CLS
DATE
PATH=D:\AMRIT;

Tuesday, October 5, 2010

Services of Operating System

Services of Operating System

Operating system services are divided into two categories
a. Services that are helpful for the user
b. Services that ensure efficient operations of the system itself. 

Services helpful for the User
  • Program execution: The Operating System is responsible for execution of all types of programs whether it be user programs or system programs. OS loads a program into memory and run that program. The program must be able end its execution either normally or my raising an execption or error.  It uses various resources available for the efficient running of all types of programs

  • I/O Operations: The main job of a computer is I/O. A running program may require I/O. The user usually cannot control I/O directly. Therefore, the operating system manages and control I/O operations and I/O device. 

  • File System Manipulation: The Operating System is responsible for making of decisions regarding the storage of all types of data or files, i.e, floppy disk/hard disk/pen drive, etc. The Operating System decides as how should the data should be manipulated and stored.

  • Communication: Computer systems allow multiple programs to be loaded into memory and executed concurrently. Processes can communicate with each other to exchange data and information. The communicating process may be running on same computer or on different computer system connected via network. Operating system move information between processes either via shared memory or through message passing.  

  • Error Detection: A user program may give error like access to illegal memory space, division by zero. Similarly error may occur in CPU or other hardware device. There may be connection failure. Therefore, OS take necessary actions, correct errors  and avoid the malfunctioning of computer system.
Services helpful for the System
  • Resource Allocation: The main objective of multi-programming is to maximize CPU utilization by running some process all the time. When one process has to wait for say I/0, the OS takes the CPU from that process and allocate to another process. This is known as scheduling. All the resources are scheduled before use and therefore it is the primary function of operating system. 

  • Accounting: Operating  system  keep  track of user process and user activities in terms of how much and what kind of computer resources are used. This recorded information is used as resource  usage statistics for a particular user or group of user.

  • Protection and Security: Operating system ensures that all access to the system resources are controlled and access of outsiders is prohibited.  The operating system uses password protection to protect user data and similar other techniques. it also prevents unauthorized access to programs and user data.

Functions of Operating System

PROCESS MANAGEMENT
  • A process is defined as a program in execution. 
  • It is more than program code.
 

To accomplish its task, a process needs certain resources like CPU time, memory files and I/O devices and as a process executes it changes its states. Each process may be in one of the following stages
  • New: The process is being created.
  • Running: Instruction are being executed.
  • Waiting: Waiting for some resource like memory, I/O , CPU time etc.
  • Ready: Process is in main memory and waiting to be assigned to CPU.
  • Terminate: The process finished execution.
An Operating System performs the following activities for processor management.
  • Creating and deleting both user and system processes.
  • Suspending and resuming processes.
  • Provide mechanisms for process synchronization.
  • Provide mechanism for process communication.

MEMORY MANAGEMENT


Main Memory is an array of addressable words or bytes that is quickly accessible. Main Memory is repository of quickly accessible data shared by CPU and I/O devices. Main Memory is volatile. Main memory is only storage device that CPU is able to address and access directly. For a program to be executed, it must be loaded into main memory. To improve CPU utilization and speed up computer response time, we keep several programs in memory.

The operating system is responsible for following activities in connection with the memory management
  • Keeping track of which part of memory are currently being used and by whom
  • Deciding which processes are to be loaded into memory
  • Allocating and deallocating memory space as needed
  • Swap IN and Swap OUT of processes
  • Managing the sharing of memory between process

FILE MANAGEMENT

A file is a collection of related information defined by the user. The files are organized into directories and sub-directories. These files resides permanently on secondary storage . All the secondary storage device have different characteristic in terms of physical organization, storage capacity, access methods and data transfer rate etc. Therefore File Management is one of the most important function of an operating system.

The Operating System is responsible for the following activities for file management
  • creating and deleting files
  • creating and deleting directories.
  • Supporting primitives for file and directories manipulation.
  • Mapping file on to secondary storage.
  • Backing up files on permanent storage media.

I/O MANAGEMENT

The two main jobs of computer are I/O and processing. The role of the operating system in computer I/O is to manage and control I/O operations. Because I/O devices vary widely in their function and speed, a variety of methods are needed to control them. These methods form the I/O sub-system.

The operating System is responsible for the following activities for I/O Management
  • buffering: Stores data being transferred between two devices or between device and application. Reasons of Buffering: Cope with a speed mismatch between the producer and consumer. and Provide adaptions for devices that have different data transfer sizes.
  • caching: Region of fast memory that holds copies of frequently used data.
  • spooling:.Is a buffer that holds output for a device such as printer
  • A general device driver interface: a translator that takes input  consist of high level commands and gives output consists of low level hardware specific instructions that are used by hardware controller
  • Drivers for specific hardware devices.
Only Device Driver know the complexities of the specific devices to which it is assigned.

Monday, October 4, 2010

System Calls

An operating system provided various types of functions and services. The user processes need to access those OS services but cannot use or execute it directly.  A system call provides an interface between a process and operating system that allow user process to request service of the operating system. It is defined as a programmatic way in which a program request services from the  operating or interact with the operating system via Application Programming Interface. These system calls are programs written in C and C++  and certain low level task where hardware is to be accessed directly  are written using assembly language. 
A system call interface check function calls in the API and invokes the necessary system call within the OS. 

For example, suppose a student want to see his / her final exam answer sheet. For this he / she writes the application and fill form. After filling form, with the permission of examination controller he/she can see examination sheet. Here we can say that, fill form is a system call to access service provided by examination cell.

Type of System Calls:

Process Control System calls
  • End, abort
  • Load, execute
  • Create process, terminate process
  • Get and set process attriburtes
  • Wait for time
  • Wait event
  • Allocate and free memory

File Management System Calls
  • Create or delete file
  • Open or close
  • Read, write or reposition
  • Get or set file attribute
Device Management System Calls
  • Request device or  release device
  • Read, write or reposition
  • Get or set device attributes
  • Attach or detach device
Information Maintenance System Calls
  • Get or set date and time
  • Get or set system data
  • Get process, file or device attribute
  • Set process, file or device attributes
Communication
  • Create or delete connection
  • Send or receive message
  • Transfer status in formation
  • Attach or detach remote device

Sunday, October 3, 2010

System Hardware Protection

Protection refers to a mechanism which controls the access of programs, processes, or users to the resources defined by a computer system. Need of Protection:

  • To prevent the access of unauthorized users and
  • To ensure that each active programs or processes in the system uses resources only as the stated policy,
  • To improve reliability by detecting latent errors.

Hardware protection is divided into 3 categories: CPU protection, Memory Protection, and I/O protection. These are explained as following below.

CPU Protection

OS must prevent the user program from getting stuck in an infinite loop or not calling system services and never return control to CPU. For this purpose timer is used which interrupts the CPU after specified periods to ensure OS maintains control. The timer period may be variable or fixed. A fixed rate clock and a counter is used to implement a variable timer. The OS initialzes the counter with some positive number. The counter is decremented with every clock tick. When counter reaches 0, a timer interrupt is generated and control is transfer is to next process. Thus timer is used to prevent the program from running too long.

Memory Protection

The area of a memory where process resides is known as process address space. OS ensures that a process cannot access memory address outside its address space. That is, a process is not allowed to access other process address space. Therefore, there is a need to determine the range of legal addresses a process can access. Using two registers, OS provide this memory protection. These register are

  • 1   Base Address: holds the smallest legal address
  • 2.  Limit Register: specifies the size of range

WWhen a process is loaded into the memory, the base address is initialized with starting address of the process address space and limit register is initialized with its size. Memory outside the range is protected by having hardware  that compare every address generated in user mode with the register. Any attempt to access the memory outside range treated as a fatal error.