• MCS (Gold Medal) The University of Lahore , Pakistan
• M.Com University of Sargodha , Pakistan
What is Operating system? • An Operating system (OS) is a software which acts as an interface between the end user and computer hardware. • Every computer must have at least one OS to run other programs. • An application like Chrome, MS Word, Games, etc needs some environment in which it will run and perform its task. • The OS helps you to communicate with the computer without knowing how to speak the computer's language. • It is not possible for the user to use any computer or mobile device without having an operating system. Computer System Structure
• Computer system can be divided into four
components: • Hardware – provides basic computing resources • CPU, memory, I/O devices • Operating system • Controls and coordinates use of hardware among various applications and users • Application programs – define the ways in which the system resources are used to solve the computing problems of the users • Word processors, compilers, web browsers, database systems, video games • Users • People, machines, other computers Organization of a Computer System As shown in Figure 1.1, the major high-level components of a computer system are: 1. Hardware, which provides basic computing resources (CPU, memory, I/O devices). 2. Operating system, which manages the use of the hardware among the various application programs for the various users and provides the user a relatively simple machine to use. 3. Applications programs that define the ways in which system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs). 4. Users, which include people, machines, other computers Organization of a Computer System
Figure 1.1. High-level components of a computer system
Operating system • The operating system provides the means for proper use of these resources in the operation of the computer system. • An operating system is similar to a government. • Like a government, it performs no useful function by itself. It simply provides an environment within which other programs can do useful work. OS Name Share
Windows 40.34
Android 37.95
iOS 15.44
Mac OS 4.34
Linux 0.95
Chrome OS 0.14
Windows Phone OS 0.06
Features of Operating System • Protected and supervisor mode • Allows disk access and file systems Device drivers Networking Security • Program Execution • Memory management Virtual Memory Multitasking • Handling I/O operations • Manipulation of the file system • Error Detection and handling • Resource allocation • Information and Resource Protection How program Run? Primary purpose of a computer system is to generate executable programs and execute them. The following are some of the main issues involved in performing these tasks.
1. Storing an executable on a secondary storage device such as hard disk
2. Loading executable from disk into the main memory 3. Setting the CPU state (PC) appropriately so that program execution could begin Fetch Decode Execute store 4. Creating multiple cooperating processes, synchronizing their access to shared data, and allowing them to communicate with each other Storage Structure Main memory ( RAM ) o Programs must be loaded into RAM to run. o Instructions and data fetched from RAM into registers. o RAM is volatile o "Medium" size and speed Other electronic ( volatile ) memory is faster, smaller, and more expensive per bit: o Registers o CPU Cache Non-volatile memory ( "permanent" storage ) is slower, larger, and less expensive per bit: o Electronic disks o Magnetic disks o Optical disks o Magnetic Tapes Storage Structure
Figure 1.3 - Storage-device hierarchy
OPERATING SYSTEM USE FOR Manage secondary storage devices • Allocate appropriate amount of disk space when files are created • Deallocate space when files are removing • Insure that a new file does not overwrite an existing file • Schedule disk requests Manage primary storage • Allocate appropriate amount of memory space when programs are to be loaded into the memory for executing • Deallocate space when processes terminate • Insure that a new process is not loaded on top of an existing process • Insure that a process does not access memory space that does not belong to it • Allow execution of programs larger in size than the available main memory Manage processes • Allow simultaneous execution of processes by scheduling the CPU(s) • Prevent deadlocks between processes • Insure integrity of shared data • Synchronize executions of cooperating processes Allow a user to manage his/her files and directories properly • User view of directory structure • Provide a mechanism that allows users to protect their files and directories Operating System Operations • An operating system is a construct that allows the user application programs to interact with the system hardware. • Operating system by itself does not provide any function but it provides an atmosphere in which different applications and programs can do useful work. • The major operations of the operating system are process management, memory management, device management and file management. These are given in detail as follows: Process Management • The operating system is responsible for managing the processes i.e assigning the processor to a process at a time. This is known as process scheduling. • The different algorithms used for process scheduling are FCFS (first come first served), SJF (shortest job first), priority scheduling, round robin scheduling etc. • There are many scheduling queues that are used to handle processes in process management. • When the processes enter the system, they are put into the job queue. • The processes that are ready to execute in the main memory are kept in the ready queue. • The processes that are waiting for the I/O device are kept in the device queue. Memory Management • Memory management plays an important part in operating system. It deals with memory and the moving of processes from disk to primary memory for execution and back again. • The activities performed by the operating system for memory management are: • The operating system assigns memory to the processes as required. This can be done using best fit, first fit and worst fit algorithms. • All the memory is tracked by the operating system i.e. it nodes what memory parts are in use by the processes and which are empty. • The operating system deallocated memory from processes as required. This may happen when a process has been terminated or if it no longer needs the memory. Device Management • There are many I/O devices handled by the operating system such as mouse, keyboard, disk drive etc. • There are different device drivers that can be connected to the operating system to handle a specific device. • The device controller is an interface between the device and the device driver. • The user applications can access all the I/O devices using the device drivers, which are device specific codes. Storage Management • Since main memory is usually too small to accommodate all the data and programs permanently, the computer system must provide secondary storage to back up main memory • To make the computer system convenient for users, the operating system provides a uniform, logical view of information storage. • The operating system abstracts from the physical properties of its storage devices to define a logical storage unit, the file. • The operating system maps files onto physical media and accesses these files via the storage devices File Management • Files are used to provide a uniform view of data storage by the operating system. All the files are mapped onto physical devices that are usually non volatile so data is safe in the case of system failure. • A file is a collection of related information defined by its creator. • Commonly, files represent programs (both source and object forms) and data. Data files may be numeric, alphabetic, alphanumeric, or binary. F • Files may be free-form (for example, text files), or they may be formatted rigidly (for example, fixed fields). Clearly, the concept of a file is an extremely general one. • The operating system implements the abstract concept of a file by managing mass storage media, such as tapes and disks, and the devices that control them. • Also, files are normally organized into directories to make them easier to use • Finally, when multiple users have access to files, it may be desirable to control by whom and in what ways (for example, read, write, append) files may be accessed. File Management
• The operating system is responsible for the following activities in
connection with file management: • Creating and deleting files • Creating and deleting directories to organize files • Supporting primitives for manipulating files and directories • Mapping files onto secondary storage • Backing up files on stable (nonvolatile) storage media. Mass-Storage Management • As we have already seen, because main memory is too small to accommodate all data and programs, and because the data that it holds are lost when power is lost, the computer system must provide secondary storage to back up main memory. • Most modern computer systems use disks as the principal on-line storage medium for both programs and data. Most programs—including compilers, assemblers, word processors, editors, and formatters—are stored on a disk until loaded into memory and then use the disk as both the source and destination of their processing. • The operating system is responsible for the following activities in connection with disk management: • Free-space management • Storage allocation • Disk scheduling Because secondary storage is used frequently, it must be used efficiently. File Management • Files are used to provide a uniform view of data storage by the operating system. All the files are mapped onto physical devices that are usually non volatile so data is safe in the case of system failure. • The files can be accessed by the system in two ways i.e. sequential access and direct access: • Sequential AccessThe information in a file is processed in order using sequential access. The files records are accessed on after another. Most of the file systems such as editors, compilers etc. use sequential access. • Direct AccessIn direct access or relative access, the files can be accessed in random for read and write operations. The direct access model is based on the disk model of a file, since it allows random accesses. Caching • Caching is an important principle of computer systems. Information is normally kept in some storage system (such as main memory). • As it is used, it is copied into a faster storage system—the cache—on a temporary basis. • When we need a particular piece of information, we first check whether it is in the cache. • If it is, we use the information directly from the cache; if it is not, we use the information from the source, putting a copy in the cache under the assumption that we will need it again soon. Protection and security • Protection and security ensures that each object is accessed correctly and only by those processes of authorized users that are allowed to do so • If a computer system has multiple users and allows the concurrent execution of multiple processes, then access to data must be regulated. • For that purpose, mechanisms ensure that files, memory segments, CPU, and other resources can be operated on by only those processes that have gained proper authorization from the operating system. • For example, memory-addressing hardware ensures that a process can execute only within its own address space. Protection and security • The timer ensures that no process can gain control of the CPU • Device-control registers are not accessible to users, so the integrity of the various peripheral devices is protected. • Protection, then, is any mechanism for controlling the access of processes or users to the resources defined by a computer system. • Protection can improve reliability by detecting hidden errors at the interfaces between component subsystems. • A protection-oriented system provides a means to distinguish between authorized and unauthorized usage Protection and security • In Windows NT parlance, this is a security ID (SID). • These numerical IDs are unique, one per user. • When a user logs in to the system, the authentication stage determines the appropriate user ID for the user. • That user ID is associated with all of the user's processes and threads. • When an ID needs to be user readable, it is translated back to the user name via the user name list. Types of Operating System • Batch operating system • The users of a batch operating system do not interact with the computer directly. Each user prepares his job on an off-line device like punch cards and submits it to the computer operator. To speed up processing, jobs with similar needs are batched together and run as a group. The programmers leave their programs with the operator and the operator then sorts the programs with similar requirements into batches. • Example = Payroll System, Bank Statements etc • The problems with Batch Systems are as follows − • Lack of interaction between the user and the job. • CPU is often idle, because the speed of the mechanical I/O devices is slower than the CPU. • Difficult to provide the desired priority. Types of Operating System Types of Operating System • Time-Sharing Operating Systems – • Each task is given some time to execute, so that all the tasks work smoothly. • Each user gets time of CPU as they use single system. • These systems are also known as Multitasking Systems. • The task can be from single user or from different users also. • The time that each task gets to execute is called quantum. • After this time interval is over OS switches over to next task. • Advantages of Time-Sharing OS: • Each task gets an equal opportunity • Less chances of duplication of software • CPU idle time can be reduced • Disadvantages of Time-Sharing OS: • Reliability problem • One must have to take care of security and integrity of user programs and data • Data communication problem Types of Operating System Types of Operating System • Distributed Operating System • Distributed systems use multiple central processors to serve multiple real-time applications and multiple users. Data processing jobs are distributed among the processors accordingly. • The processors communicate with one another through various communication lines (such as high-speed buses or telephone lines). • Independent systems possess their own memory unit and CPU. • These are referred as loosely coupled systems or distributed systems. • Processors in a distributed system may vary in size and function. • These processors are referred as sites, nodes, computers, and so on. • The major benefit of working with these types of operating system is that it is always possible that one user can access the files or software which are not actually present on his system but on some other system connected within this network i.e., remote access is enabled within the devices connected in that network. Types of Operating System • Distributed Operating System
• Distributed Operating System
Types of Operating System • Advantages of Distributed Operating System: • Failure of one will not affect the other network communication, as all systems are independent from each other • Electronic mail increases the data exchange speed • Since resources are being shared, computation is highly fast and durable • Load on host computer reduces • These systems are easily scalable as many systems can be easily added to the network • Delay in data processing reduces • Disadvantages of Distributed Operating System: • Failure of the main network will stop the entire communication • To establish distributed systems the language which are used are not well defined yet • These types of systems are not readily available as they are very expensive. Not only that the underlying software is highly complex and not understood well yet Types of Operating System • 4. Network Operating System – These systems run on a server and provide the capability to manage data, users, groups, security, applications, and other networking functions. • These type of operating systems allow shared access of files, printers, security, applications, and other networking functions over a small private network. • One more important aspect of Network Operating Systems is that all the users are well aware of the underlying configuration, of all other users within the network, their individual connections etc. and that’s why these computers are popularly known as tightly coupled systems. Types of Operating System • 4. Network Operating System – Types of Operating System • Advantages of Network Operating System: • Highly stable centralized servers • Security concerns are handled through servers • New technologies and hardware up-gradation are easily integrated to the system • Server access are possible remotely from different locations and types of systems • Disadvantages of Network Operating System: • Servers are costly • User has to depend on central location for most operations • Maintenance and updates are required regularly Real-Time Operating System • These types of OSs serves the real-time systems. The time interval required to process and respond to inputs is very small. This time interval is called response time. • Real-time systems are used when there are time requirements are very strict like air traffic control systems, robots etc • For example, Scientific experiments, medical imaging systems, industrial control systems, weapon systems, robots, air traffic control systems, etc. Special-Purpose Systems • There are, however, special purpose systems with requirements different from those of many of the systems we have described. 1 Real time embedded systems • Embedded computers are the most prevalent form of computers in existence. • These devices are found everywhere, from car engines and manufacturing robots to VCRs and microwave ovens. • They tend to have very specific tasks. • The systems they run on are usually primitive, and so the operating systems provide limited features. • Usually, they have little or no user interface, preferring to spend their time monitoring and managing hardware devices, such as automobile engines and robotic arms. • These embedded systems vary considerably. Some are general-purpose computers, running standard operating systems—such as UNIX—with special-purpose applications to implement the functionality. • Systems that control scientific experiments, medical imaging systems, industrial control systems, and certain display systems are real-time systems. 2 Multimedia Systems • Most operating systems are designed to handle conventional data such as text files, programs, word- processing documents, and spreadsheets. • However, a recent trend in technology is the incorporation of multimedia data into computer systems. • Multimedia data consist of audio and video files as well as conventional files. These data differ from conventional data in that multimedia data—such as frames of video—must be delivered (streamed) according to certain time restrictions (for example, 30 frames per second). • Multimedia describes a wide range of applications that are in popular use today. These include audio files such as MP3 DVD movies, video conferencing, and short video clips of movie previews or news stories downloaded over the Internet. • Multimedia applications may also include live webcasts (broadcasting over the World Wide Web) of speeches or sporting events and even live webcams that allow a viewer in Manhattan to observe customers at a cafe in Paris. • Multimedia applications need not be either audio or video; rather, a multimedia application often includes a combination of both. 3 Handheld Systems • Handheld systems include personal digital assistants (PDAs), such as Palm and Pocket-PCs, and cellular telephones, many of which use special-purpose embedded operating systems. • Developers of handheld systems and applications face many challenges, most of which are due to the limited size of such devices. • For example, a PDA is typically about 5 inches in height and 3 inches in width, and it weighs less than one-half pound. • Because of their size, most handheld devices have a small amount of memory, slow processors, and small display screens. • The amount of physical memory in a handheld depends upon the device, but typically is somewhere between 512 KB and 128 MB. • Currently, not many handheld devices use virtual memory techniques, so program developers must work within the confines of limited physical memory. • A second issue of concern to developers of handheld devices is the speed of the processor used in the devices. Processors for most handheld devices run at a fraction of the speed of a processor in a PC. • Faster processors require more power. To include a faster processor in a handheld device would require a larger battery, which would take up more space and would have to be replaced (or recharged) more frequently. • Most handheld devices use smaller, slower processors that consume less power. Types of Computing Environments • A computer system uses many devices, arranged in different ways to solve many problems. This constitutes a computing environment where many computers are used to process and exchange information to handle multiple issues. • The different types of Computing Environments are: Types of computing environment • Personal Computing Environment • In the personal computing environment, there is a single computer system. All the system processes are available on the computer and executed there. The different devices that constitute a personal computing environment are laptops, mobiles, printers, computer systems, scanners etc. • Time Sharing Computing Environment • The time sharing computing environment allows multiple users to share the system simultaneously. Each user is provided a time slice and the processor switches rapidly among the users according to it. Because of this, each user believes that they are the only ones using the system. • Client Server Computing Environment • In client server computing, the client requests a resource and the server provides that resource. A server may serve multiple clients at the same time while a client is in contact with only one server. Both the client and server usually communicate via a computer network but sometimes they may reside in the same system. Types of computing environment • Distributed Computing Environment • A distributed computing environment contains multiple nodes that are physically separate but linked together using the network. All the nodes in this system communicate with each other and handle processes in tandem. Each of these nodes contains a small part of the distributed operating system software. • Cloud Computing Environment • The computing is moved away from individual computer systems to a cloud of computers in cloud computing environment. The cloud users only see the service being provided and not the internal details of how the service is provided. This is done by pooling all the computer resources and then managing them using a software. • Cluster Computing Environment • The clustered computing environment is similar to parallel computing environment as they both have multiple CPUs. However a major difference is that clustered systems are created by two or more individual computer systems merged together which then work parallel to each other. Operating System Services • Operating systems provide an environment for execution of programs and services to programs and users • User Interfaces - Means by which users can issue commands to the system. Depending on the system these may be a command-line interface ( e.g. sh, csh, ksh, tcsh, etc. ), a GUI interface ( e.g. Windows, X-Windows, KDE, Gnome, etc. ), or a batch command systems. The latter are generally older systems using punch cards of job-control language, JCL, but may still be used today for specialty systems designed for a single purpose. • Program Execution - The OS must be able to load a program into RAM, run the program, and terminate the program, either normally or abnormally. • I/O Operations - The OS is responsible for transferring data to and from I/O devices, including keyboards, terminals, printers, and storage devices. Operating System Services • File-System Manipulation - In addition to raw data storage, the OS is also responsible for maintaining directory and subdirectory structures, mapping file names to specific blocks of data storage, and providing tools for navigating and utilizing the file system. • Communications - Inter-process communications, IPC, either between processes running on the same processor, or between processes running on separate processors or separate machines. May be implemented as either shared memory or message passing, ( or some systems may offer both. ) • Error Detection - Both hardware and software errors must be detected and handled appropriately, with a minimum of harmful consequences. Some systems may include complex error avoidance or recovery systems, including backups, RAID drives, and other redundant systems. Debugging and diagnostic tools aid users and administrators in tracing down the cause of problems. Operating System Services • Error Detection • May occur in the CPU and memory hardware, in I/O devices, in user program • For each type of error, OS should take the appropriate action to ensure correct and consistent computing • Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system Operating System Services • Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing • Resource Allocation - • When multiple users or multiple jobs running concurrently, resources must be allocated to each of them • E.g. CPU cycles, main memory, storage space, and peripheral devices. • Some resources are managed with generic systems and others with very carefully designed and specially tuned systems, customized for a particular resource and operating environment. • Accounting - • Keeping track of system activity and resource usage, either for billing purposes or for statistical record keeping that can be used to optimize future performance. Operating System Services • Protection and Security - • The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other • Protection involves ensuring that all access to system resources is controlled • Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts • Preventing harm to the system and to resources, either through wayward internal processes or malicious outsiders. • Authentication, ownership, and restricted access are obvious parts of this system. • Highly secure systems may log all process activity down to excruciating detail, and security regulation dictate the storage of those records on permanent non-erasable medium for extended times in secure ( off-site ) facilities. A view of operating system services User Operating-System Interface • Command Interpreter • Sometimes implemented in kernel, sometimes by systems program • In some operating systems, the command interpreter is called the shell. • In some systems the CI may be incorporated directly into the kernel. • More commonly the CI is a separate program that launches once the user logs in or otherwise accesses the system. Command interpreters have a large range of commands and queries available for different operations. Also, it is much faster to type than to click as is done using graphical user interfaces.. • There are some systems that don’t have enough resources to support graphical user interfaces. In those cases, command interpreters can be used. • Scientists and engineers often used command interpreters in scientific environments. Technically advanced users also prefer command interpreters as compared to graphical user interfaces. • People with visual disabilities use command interpreters as they cannot work with graphical user interfaces. Commands and instructions can be displayed using braille displays in command interpreters. The Bourne shell command interpreter in Solaris 10 User Operating-System Interface • Graphical User Interface, GUI • Generally implemented as a desktop metaphor, with file folders, trash cans, and resource icons. • Icons represent some item on the system, and respond accordingly when the icon is activated. • First developed in the early 1970's at Xerox PARC research facility. • In some systems the GUI is just a front end for activating a traditional command line interpreter running in the background. In others the GUI is a true graphical shell in its own right. • Mac has traditionally provided ONLY the GUI interface. With the advent of OSX ( based partially on UNIX ), a command line interface has also become available. • Because mice and keyboards are impractical for small mobile devices, these normally use a touch-screen interface today, that responds to various patterns of swipes or "gestures". When these first came out they often had a physical keyboard and/or a trackball of some kind built in, but today a virtual keyboard is more commonly implemented on the touch screen. The iPad touchscreen Difference between command interpreter and GUI • Command interpreters work on text-based interfaces where the users can type their requests and queries as required and obtain the desired results. In comparison to this, graphical user interfaces contain all the information in visual form where icons, windows etc. can be used to access and manipulate data. • Experienced users find command interpreters much more useful as it is faster to type commands and get results. Naive users prefer graphical user interfaces as they are in a pictorial format and easy to use. User Operating-System Interface • Choice of interface • Most modern systems allow individual users to select their desired interface, and to customize its operation, as well as the ability to switch between different interfaces as needed. System administrators generally determine which interface a user starts with when they first log in. • GUI interfaces usually provide an option for a terminal emulator window for entering command-line commands. • Command-line commands can also be entered into shell scripts, which can then be run like any other programs.