Download Operating Systems for data science and more Lecture notes Information Technology in PDF only on Docsity!
CHAPTER 1: INTRODUCTION TO OPERATING SYSTEM
Introduction to Operating system An operating system ( OS ) is system software that manages computer hardware and software resources and provides common services for computer programs. All computer programs, excluding firmware, require an operating system to function. An operating system is a program that acts as an interface between the user and the computer hardware and controls the execution of all kinds of application programs and assistant system software programs (i.e. Utilities). Basic importance of the operating system
- Operating system behaves as a resource manager. It utilizes the computer in a cost effective manner. It keeps account of different jobs and the where about of their results and locations in the memory.
- Operating system schedules jobs according to their priority passing control from one program to the next. The overall function of job control is especially important when there are several uses (a multi user environment)
- Operating system makes a communication link user and the system and helps the user to run application programs properly and get the required output
- Operating system has the ability to fetch the programs in the memory when required and not all the Operating system to be loaded in the memory at the same time, thus giving the user the space to work in the required package more conveniently and easily
- Operating system helps the user in file management. Making directories and saving files in them is a very important feature of operating system to organize data according to the needs of the user
- Multiprogramming is a very important feature of operating system. It schedules and controls the running of several programs at ones
- It provides program editors that help the user to modify and update the program lines
- Debugging aids provided by the operating system helps the user to detect and rename errors in programs
- Disk maintenance ability of operating system checks the validity of data stored on diskettes and other storage to make corrections to erroneous data Operating Systems Terminology’s Processes: A process is an instance of a program running in a computer. A program in the execution is called a Process. Process is not the same as program. A process is more than a program code (Program Code + Data + Execution status). Files: A collection of data or information that has a name, called the filename. Almost all information stored in a computer must be in a file. There are many different types of files: data files, text files , program files, directory files, and so on. Different types of files store different types of information. For example, program files store programs, whereas text files store text. A system call is a way for programs to interact with the operating system. A computer program makes a system call when it makes a request to the operating system's kernel. System calls are used for hardware services, to create or execute a process, and for communicating with kernel services, including application and process scheduling. Shell AND kernel A shell is a software interface that's often a command line interface that enables the user to interact with the computer. Some examples of shells are MS-DOS Shell, command.com, csh, ksh, and sh. Below is a picture and example of what a Terminal window with an open shell. A Kernel is first section of the operating system to load into memory. As the center of the operating system, the kernel needs to be small, efficient and loaded into a protected area in the memory; so as not to be overwritten. It can be responsible for such things as disk drive management, interrupt handler, file management, memory management, process management, etc. Virtual Machines: A virtual machine (VM) is a software program or operating system that not only exhibits the behavior of a separate computer, but is also capable of performing tasks such as running applications and programs like a separate computer. A virtual machine, usually known as a guest is created within another computing environment referred as a "host." Multiple virtual machines can exist within a single host at one time.
multiprogramming in which a computer program will be able to perform multiple jobs at the
same time.The introduction of multiprogramming was a major part in the development of operating systems because it allowed a CPU to be busy nearly 100 percent of the time that it was in operation. Another major development during the third generation was the phenomenal growth of minicomputers, starting with the DEC PDP-1 in 1961. The PDP-1 had only 4K of 18- bit words, but at $120,000 per machine (less than 5 percent of the price of a 7094), it sold like hotcakes. These microcomputers help create a whole new industry and the development of more PDP's. These PDP's helped lead to the creation of personal computers which are created in the fourth generation. The Fourth Generation (1980-Present Day) The fourth generation of operating systems saw the creation of personal computing. Although these computers were very similar to the minicomputers developed in the third generation, personal computers cost a very small fraction of what minicomputers cost. A personal computer was so affordable that it made it possible for a single individual could be able to own one for personal use while minicomputers where still at such a high price that only corporations could afford to have them. One of the major factors in the creation of personal computing was the birth of Microsoft and the Windows operating system. The windows Operating System was created in 1975 when Paul Allen and Bill Gates had a vision to take personal computing to the next level. They introduced the MS-DOS in 1981 although it was effective it created much difficulty for people who tried to understand its cryptic commands. Windows went on to become the largest operating system used in techonology today with releases of Windows 95, Windows 98, WIndows XP (Which is currently the most used operating system to this day), and their newest operating system Windows 7. Along with Microsoft, Apple is the other major operating system created in the 1980's. Steve Jobs, co founder of Apple, created the Apple Macintosh which was a huge success due to the fact that it was so user friendly. Windows development throughout the later years were influenced by the Macintosh and it created a strong competition between the two companies. Today all of our electronic devices run off of operating systems, from our computers and smartphones, to ATM machines and motor vehicles. And as technology advances, so do operating systems. Operating System Structure An operating system might have many structure. According to the structure of the operating system; operating systems can be classified into many categories. Some of the main structures used in operating systems are:
The layered are selected such that each user functions and services of only lower level layer. The first layer can be debugged wit out any concern for the rest of the system. It user basic hardware to implement this function once the first layer is debugged., it‟s correct functioning can be assumed while the second layer is debugged & soon. If an error is found during the debugged of particular layer, the layer must be on that layer, because the layer below it already debugged. Because of this design of the system is simplified when operating system is broken up into layer. Os/2 operating system is example of layered architecture of operating system another example is earlier version of Windows NT. The main disadvantage of this architecture is that it requires an appropriate definition of the various layers & a careful planning of the proper placement of the layer.
3. Virtual memory architecture of operating system Virtual machine is an illusion of a real machine. It is created by a real machine operating system, which make a single real machine appears to be several real machine. The architecture of virtual machine is shown above. The best example of virtual machine architecture is IBM 370 computer. In this system each user can choose a different operating system. Actually, virtual machine can run several operating systems at once, each of them on its virtual machine. Its multiprogramming shares the resource of a single machine in different manner. The concepts of virtual machine are:- a) Control program (cp):- cp creates the environment in which virtual machine can execute. It gives to each user facilities of real machine such as processor, storage I/0 devices.
b) conversation monitor system (cons):- cons is a system application having features of developing program. It contains editor, language translator, and various application packages. c) Remote spooling communication system (RSCS):- provide virtual machine with the ability to transmit and receive file in distributed system. d) IPCS (interactive problem control system):- it is used to fix the virtual machine software problems.
4. client/server architecture of operating system A trend in modern operating system is to move maximum code into the higher level and remove as much as possible from operating system, minimising the work of the kernel. The basic approach is to implement most of the operating system functions in user processes to request a service, such as request to read a particular file, user send a request to the server process, server checks the parameter and finds whether it is valid or not, after that server does the work and send back the answer to client server model works on request- response technique i.e. Client always send request to the side in order to perform the task, and on the other side, server gates complementing that request send back response. The figure below shows client server architecture. Client Process Cleint Process Process Server Terminal server …………. File server Memory server Kernel Fig: The client-server model In this model, the main task of the kernel is to handle all the communication between the client and the server by splitting the operating system into number of ports, each of which only handle some specific task. I.e. file server, process server, terminal server and memory service. Another advantage of the client-server model is it‟s adaptability to user in distributed system. If the client communicates with the server by sending it the message, the client need not know whether it was send a ……. Is the network to a server on a remote machine? As in case of client, same thing happen and occurs in client side that is a request was send and a reply come back. Operating System ─ Types 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 sortsthe programs with similar requirements into batches.
The advantages of distributed systems are as follows:
- With resource sharing facility, a user at one site may be able to use the resources available at another.
- Speedup the exchange of data with one another via electronic mail.
- If one site fails in a distributed system, the remaining sites can potentially continue operating.
- Better service to the customers.
- Reduction of the load on the host computer.
- Reduction of delays in data processing. Network Operating System A Network Operating System runs on a server and provides the server the capability to manage data, users, groups, security, applications, and other networking functions. The primary purpose of the network operating system is to allow shared file and printer access among multiple computers in a network, typically a local area network (LAN), a private network or to other networks. Examples of network operating systems include Microsoft Windows Server 2003, Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD. The advantages of network operating systems are as follows:
- Centralized servers are highly stable.
- Security is server managed.
- Upgrades to new technologies and hardware can be easily integrated into thesystem.
- Remote access to servers is possible from different locations and types of systems.The disadvantages of network operating systems are as follows:
- High cost of buying and running a server.
- Dependency on a central location for most operations.
- Regular maintenance and updates are required. Real-Time Operating System A real-time system is defined as a data processing system in which the time interval required to process and respond to inputs is so small that it controls the environment. The time taken by the system to respond to an input and display of required updated information is termed as the response time. So in this method, the response time is very less as compared to online processing. Real-time systems are used when there are rigid time requirements on the operation of a processor or the flow of data and real-time systems can be used as a control device in a dedicatedapplication. A real-time operating system must have well-defined, fixed time constraints, otherwise the system will fail. For example, Scientific experiments, medical imaging systems, industrial control systems, weapon systems, robots, air traffic control systems, etc. There are two types of real-time operating systems. 1) Hard real-time systems: Hard real-time systems guarantee that critical tasks complete on time. In hard real-time systems, secondary storage is limited or missing and the data is stored in
ROM. In these systems, virtual memory is almost never found. 2) Soft real-time systems: Soft real-time systems are less restrictive. A critical real-time task gets priority over other tasks and retains the priority until it completes. Soft real-time systems have limited utility than hard real-time systems. For example, multimedia, virtual reality, Advanced Scientific Projects like undersea exploration and planetary rovers, etc. Operating System ─ Properties Batch Processing Batch processing is a technique in which an Operating System collects the programs and data together in a batch before processing starts. An operating system does the following activities related to batch processing:
- The OS defines a job which has predefined sequence of commands, programs and data as a single unit.
- The OS keeps a number a jobs in memory and executes them without any manual information.
- Jobs are processed in the order of submission, i.e., first come first served fashion.
- When a job completes its execution, its memory is released and the output for the job gets copied into an output spool for later printing or processing.
- A program that is loaded into memory and is executing is commonly referred to as a process.
- When a process executes, it typically executes for only a very short time before it either finishes or needs to perform I/O.
- Since interactive I/O typically runs at slower speeds, it may take a long time to complete. During this time, a CPU can be utilized by another process.
- The operating system allows the users to share the computer simultaneously. Since each action or command in a time-shared system tends to be short, only a little CPU time is needed for each user.
- As the system switches CPU rapidly from one user/program to the next, each user is given the impression that he/she has his/her own CPU, whereas actually one CPU is being shared among many users. Multiprogramming Sharing the processor, when two or more programs reside in memory at the same time, is referred as multiprogramming. Multiprogramming assumes a single shared processor. Multiprogramming increases CPU utilization by organizing jobs so that the CPU always has one to execute. The following figure shows the memory layout for a multiprogramming system.
An OS does the following activities related to multiprogramming.
- The operating system keeps several jobs in memory at a time.
- This set of jobs is a subset of the jobs kept in the job pool.
- The operating system picks and begins to execute one of the jobs in the memory.
- Multiprogramming operating systems monitor the state of all active programs and system resources using memory management programs to ensures that the CPU is never idle, unless there are no jobs to process. Advantage
- High and efficient CPU utilization.
- User feels that many programs are allotted CPU almost simultaneously. Disadvantages
- CPU scheduling is required.
- To accommodate many jobs in memory, memory management is required. Interactivity Interactivity refers to the ability of users to interact with a computer system. An Operating system does the following activities related to interactivity:
- Provides the user an interface to interact with the system.
- Manages input devices to take inputs from the user. For example, keyboard.
- Manages output devices to show outputs to the user. For example, Monitor. The response time of the OS needs to be short, since the user submits and waits for the result. Real-Time Systems Real-time systems are usually dedicated, embedded systems. An operating system does the following activities related to real-time system activity.
- In such systems, Operating Systems typically read from and react to sensor data.
- The Operating system must guarantee response to events within fixed periods of time to ensure correct performance. Distributed Environment A distributed environment refers to multiple independent CPUs or processors in a computer system. An operating system does the following activities related to distributed environment:
- The OS distributes computation logics among several physical processors.
- The processors do not share memory or a clock. Instead, each processor has its own local memory.
- The OS manages the communications between the processors. They communicate with each other through various communication lines. Spooling Spooling is an acronym for simultaneous peripheral operations on line. Spooling refers to putting data of various I/O jobs in a buffer. This buffer is a special area in memory or hard disk which is accessible to I/O devices.
job and minor control details. A language used to construct statements that identify a particular job to be run and specify the job's requirements to the operating system under which it will run. A programming language used to specify the manner, timing, and other requirements of execution of a task or set of tasks submitted for execution, especially in background, on a multitasking computer; a programming language for controlling job execution. Command language Sometimes referred to as a command script , a command language is a language used for executing a series of commands instructions that would otherwise be executed at the prompt ( text or symbols used to represent the system's readiness to perform the next ). A good example of a command language is Microsoft Windows batch files(A batch file or batch job is a collection, or list, of commands that are processed in sequence often without requiring user input or intervention). Although command languages are useful for executing a series of commands, their functionality is limited to what is available at the command line which can make them easier to learn. Advantages of command languages
- Very easy for all types of users to write.
- Do not require the files to be compiled.
- Easy to modify and make additional commands.
- Very small files.
- Do not require any additional programs or files that are not already found on the operating system. Disadvantages of command languages
- Can be limited when comparing with other programming languages or scripting languages.
- May not execute as fast as other languages or compiled programs.
- Some command languages often offer little more than using the commands available for the operating system used.
CHAPTER 2: PROCESS MANAGEMENT
Definition of a Process and terms A process is basically a program in execution. The execution of a process must progress in a sequential fashion. A process is defined as an entity which represents the basic unit of work to be implemented in a system. To put it in simple terms, we write our computer programs in a text file and when we execute this program, it becomes a process which performs all the tasks mentioned in the program. When a program is loaded into the memory and it becomes a process, it can be divided into four sections ─ stack, heap, text and data. The following image shows a simplified layout of a process inside main memory: S.N. Component & Description 1 Stack:^ The^ process^ Stack^ contains^ the^ temporary^ data^ such^ asmethod/function parameters, return address, and local variables. (^2) Heap This is a dynamically allocated memory to a process during its runtime. 3 Text^ This^ includes^ the^ current^ activity^ represented^ by^ the^ value^ of^ Program^ Counterand the contents of the processor's registers. (^4) Data This section contains the global and static variables.
Each thread has its own stack. Since thread will generally call different procedures and thus a different execution history. This is why thread needs its own stack. An operating system that has thread facility, the basic unit of CPU utilization is a thread. A thread has or consists of a program counter (PC), a register set, and a stack space. Threads are not independent of one other like processes as a result threads shares with other threads their code section, data section, OS resources also known as task, such as open files and signals. Theads share the resources allocated to a process. Processes Vs Threads As we mentioned earlier that in many respect threads operate in the same way as that of processes. Some of the similarities and differences are: Similarities
- Like processes threads share CPU and only one thread active (running) at a time.
- Like processes, threads within a processes, threads within a processes execute sequentially.
- Like processes, thread can create children.
- And like process, if one thread is blocked, another thread can run. Differences
- Unlike processes, threads are not independent of one another.
- Unlike processes, all threads can access every address in the task. hence threads can interfere with each other.
- Unlike processes, thread are design to assist one other. Note that processes might or might not assist one another because processes may originate from different users. Why Threads? Following are some reasons why we use threads in designing operating systems.
- A process with multiple threads make a great server for example printer server.
- Because threads can share common data, they do not need to use interprocess communication.
- Because of the very nature, threads can take advantage of multiprocessors. Threads are cheap in the sense that
- They only need a stack and storage for registers therefore, threads are cheap to create.
- Threads use very little resources of an operating system in which they are working. That is, threads do not need new address space, global data, program code or operating system resources.
- Context switching are fast when working with threads. The reason is that we only have to save and/or restore PC program counter, SP stack pointer and registers. But this cheapness does not come free - the biggest drawback is that there is no protection between threads. Thread levels (User-level & Kernel-level)
User-Level Threads User-level threads implement in user-level libraries, rather than via systems calls, so thread switching does not need to call operating system and to cause interrupt to the kernel. In fact, the kernel knows nothing about user-level threads and manages them as if they were single-threaded processes. Advantages: The most obvious advantage of this technique is that a user-level threads package can be implemented on an Operating System that does not support threads. Some other advantages are
- User-level threads does not require modification to operating systems.
- Simple Representation: Each thread is represented simply by a PC, registers, stack and a small control block, all stored in the user process address space.
- Simple Management: This simply means that creating a thread, switching between threads and synchronization between threads can all be done without intervention of the kernel.
- Fast and Efficient: Thread switching is not much more expensive than a procedure call. Disadvantages:
- There is a lack of coordination between threads and operating system kernel. Therefore, process as whole gets one time slice irrespect of whether process has one thread or 1000 threads within. It is up to each thread to relinquish control to other threads.
- User-level threads requires non-blocking systems call i.e., a multithreaded kernel. Otherwise, entire process will blocked in the kernel, even if there are runable threads left in