Karpov basics of operating systems. Operating systems basics. Lecture course. Karpov V.E., Konkov K.A. OS evolution. Fundamental problems. Layers of Abstraction

Introduction Definition of the operating system The operating system most determines the appearance of the entire computing system generally. Despite this, users who actively use computing technology often experience difficulty when trying to define an operating system. This is partly due to the fact that the OS performs two essentially unrelated functions: providing convenience to the user-programmer by providing an advanced machine for him and increasing the efficiency of using the computer by rationally managing its resources. The OS as an Extended Machine Using most computers at the machine language level is difficult, especially when it comes to input/output. For example, to organize reading a data block from floppy disk the programmer can use 16 different commands, each of which requires 13 parameters, such as the block number on the disk, the sector number on the track, etc. When the disk operation is completed, the controller returns 23 values ​​​​reflecting the presence and types of errors that, Obviously, it needs to be analyzed. Even if you don’t become familiar with the real problems of I/O programming, it is clear that there would not be many programmers who would be willing to directly engage in programming these operations. When working with a disk, the programmer-user only needs to represent it as a certain set of files, each of which has a name. Working with a file involves opening it, reading or writing it, and then closing the file. Questions such as whether advanced frequency modulation should be used when recording or the current state of the read head movement motor should not worry the user. A program that hides all the realities of the hardware from the programmer and provides the ability to simply, conveniently view, read or write specified files is, of course, an operating system. Just as the OS shields programmers from the disk drive hardware and provides it with a simple file interface, the operating system takes care of all the unpleasant stuff associated with interrupt handling, timer and RAM management, and other low-level problems. In each case, the abstract, imaginary machine with which, thanks to the operating system, the user can now deal, is much simpler and more convenient to use than the real hardware underlying this abstract machine. From this point of view, the function of the OS is to provide the user with some extended or virtual machine that is easier to program and work with than the actual hardware that makes up the real machine. OS as a resource management system The idea that the OS is primarily a system that provides a convenient interface to users corresponds to a top-down view. Another view, from the bottom up, gives an idea of ​​the OS as a mechanism that controls all parts of a complex system. Modern computing systems consist of processors, memory, timers, disks, magnetic tape drives, network communications equipment, printers and other devices. According to the second approach, the function of the OS is to distribute processors, memory, devices, and data among processes competing for these resources. The OS must manage all the resources of the computer in such a way as to ensure maximum efficiency of its functioning. The efficiency criterion can be, for example, the throughput or reactivity of the system. Resource management involves solving two general tasks that do not depend on the type of resource: . resource planning - that is, determining to whom, when, and for divisible resources and in what quantity, it is necessary to allocate a given resource; to a large extent determines whether the OS is a time-sharing system, a batch processing system, or a real-time system. Evolution of the OS First period (1945 -1955) It is known that the computer was invented by the English mathematician Charles Babage at the end of the eighteenth century. His “analytical engine” was never able to really work because the technology of that time did not meet the requirements for the manufacture of precision mechanics parts that were necessary for computer technology. It is also known that this computer did not have an operating system. Some progress in the creation of digital computers occurred after the Second World War. In the mid-40s, the first tube computing devices were created. At that time, the same group of people participated in the design, operation, and programming of the computer. It was more of a research work in the field of computer technology, rather than the use of computers as a tool for solving any practical problems from other applied areas. Programming was carried out exclusively in machine language. There was no talk about operating systems; all tasks of organizing the computing process were solved manually by each programmer from the control panel. There was no other system software other than libraries of mathematical and utility routines. Second period (1955 - 1965) Began in the mid-50s new period in the development of computer technology, associated with the emergence of a new technical base - semiconductor elements. Second-generation computers became more reliable, now they were able to work continuously for so long that they could be entrusted with performing truly practically important tasks. It was during this period that the personnel was divided into programmers and operators, operators and computer developers. During these years, the first algorithmic languages ​​appeared, and consequently the first system programs - compilers. The cost of CPU time has increased, requiring a reduction in the time overhead between program runs. The first batch processing systems appeared, which simply automated the launch of one program after another and thereby increased the processor load factor. Batch processing systems were the prototype of modern operating systems; they became the first system programs designed to manage the computing process. During the implementation of batch processing systems, a formalized task control language was developed, with the help of which the programmer informed the system and the operator what work he wanted to perform on the computer. A collection of several tasks, usually in the form of a deck of punched cards, is called a task package. Third period (1965 - 1980) The next important period in the development of computers dates back to 1965-1980. At this time, there was a transition in the technical base from individual semiconductor elements such as transistors to integrated circuits, which gave much greater opportunities to the new, third generation of computers. This period was also characterized by the creation of families of software-compatible machines. The first family of software-compatible machines built on integrated circuits was the IBM/360 series of machines. Built in the early 60s, this family was significantly superior to second-generation machines in terms of price/performance. Soon the idea of ​​software-compatible machines became generally accepted. Software compatibility also required operating system compatibility. Such operating systems would need to run on both large and small computing systems, with large and small numbers of peripherals, in commercial and scientific research applications. Operating systems built to satisfy all these conflicting requirements turned out to be extremely complex monsters. They consisted of many millions of lines of assembly code, written by thousands of programmers, and contained thousands of errors, causing an endless stream of corrections. With each new version of the operating system, some errors were corrected and others were introduced. However, despite its enormous size and many problems, OS/360 and other similar operating systems on third-generation machines did satisfy most consumer requirements. The most important achievement of the OS of this generation was the implementation of multiprogramming. Multiprogramming is a way of organizing a computing process in which several programs are alternately executed on one processor. While one program is performing an I/O operation, the processor is not idle, as was the case when executing programs sequentially (single-program mode), but is executing another program (multi-program mode). In this case, each program is loaded into its own section of RAM, called a partition. Another innovation is spooling. Spooling at that time was defined as a way of organizing the computing process, according to which tasks were read from punched cards onto disk at the pace at which they appeared in the computer center, and then, when the next task was completed, a new task was loaded from disk into the free partition . Along with the multiprogram implementation of batch processing systems, a new type of OS has emerged - time sharing systems. The multiprogramming option used in time-sharing systems is aimed at creating for each individual user the illusion of sole use of the computer. Fourth period (1980 - present) The next period in the evolution of operating systems is associated with the advent of large-scale integrated circuits (LSI). During these years, there was a sharp increase in the degree of integration and a reduction in the cost of microcircuits. The computer became available to the individual, and the era of personal computers began. From an architectural point of view, personal computers were no different from the class of minicomputers such as the PDP-11, but their prices were significantly different. If the minicomputer made it possible for a department of an enterprise or a university to have its own computer, then the personal computer made this possible for an individual. Computers became widely used by non-specialists, which required the development of "friendly" software, which put an end to the caste of programmers. The operating system market was dominated by two systems: MS-DOS and UNIX. The single-program, single-user MS-DOS OS was widely used for computers built on the Intel 8088, and later 80286, 80386 and 80486 microprocessors. The multi-program, multi-user UNIX OS dominated among "non-Intel" computers, especially those built on high-performance RISC processors. In the mid-80s, networks of personal computers running under network or distributed operating systems began to rapidly develop. In networked OSes, users must be aware of the presence of other computers and must log into another computer to use its resources, mainly files. Each machine on the network runs its own local operating system, different from the OS standalone computer availability additional funds, allowing the computer to work on the network. The network OS has no fundamental differences from the OS of a single-processor computer. It necessarily contains software support for network interface devices (network adapter driver), as well as tools for remote login to other computers on the network and tools for accessing remote files, but these additions do not significantly change the structure of the operating system itself. OS classification Operating systems may differ in the implementation features of internal algorithms for managing the main computer resources (processors, memory, devices), features of the design methods used, types of hardware platforms, areas of use and many other properties. Below is a classification of OS according to several of the most basic characteristics. Features of resource management algorithms The effectiveness of the entire network OS as a whole largely depends on the effectiveness of algorithms for managing local computer resources. Therefore, when characterizing a network OS, they often cite the most important features of the implementation of OS functions for managing processors, memory, and external devices of an autonomous computer. For example, depending on the characteristics of the processor control algorithm used, operating systems are divided into multi-tasking and single-tasking, multi-user and single-user, systems that support multi-threaded processing and those that do not, multi-processor and single-processor systems. Multitasking support. Based on the number of simultaneously performed tasks, operating systems can be divided into two classes: . single-tasking (for example, MS-DOS, MSX) etc. multitasking (OC EC, OS/2, UNIX, Windows 95). Single-tasking OSes mainly perform the function of providing a virtual machine to the user, making it easier and more convenient process user interaction with the computer. Single-tasking operating systems include peripheral device management tools, file management tools, and user communication tools. Multitasking OS, in addition to the above functions, manages the division of shared resources such as the processor, RAM, files and external devices. Support for multi-user mode. Based on the number of concurrent users, operating systems are divided into: . single-user (MS-DOS, Windows 3.x, early versions OS/2); An asymmetric OS runs entirely on only one of the system processors, distributing applied problems for other processors. A symmetric OS is completely decentralized and uses the entire pool of processors, dividing them between system and application tasks. Above we discussed the characteristics of the OS related to the management of only one type of resource - the processor. The features of other local resource management subsystems—memory, file, and input/output device management subsystems—have an important influence on the appearance of the operating system as a whole and on the possibilities of its use in a particular area. The specificity of the OS is also manifested in the way it implements network functions: recognition and redirection of requests to remote resources to the network, transmission of messages over the network, execution of remote requests. When implementing network functions, a set of tasks arises related to the distributed nature of data storage and processing on the network: maintaining reference information about all resources and servers available on the network, addressing interacting processes, ensuring access transparency, data replication, reconciliation of copies, maintaining data security. Features of hardware platforms The properties of the operating system are directly influenced by the hardware on which it is designed. Based on the type of hardware, operating systems of personal computers, minicomputers, mainframes, clusters and computer networks are distinguished. Among the listed types of computers, there can be both single-processor and multiprocessor options. In any case, the specifics of the hardware are usually reflected in the specifics of the operating systems. Obviously the OS big car is more complex and functional than a personal computer OS. Thus, in the OS of large machines, functions for planning the flow of tasks being performed are obviously implemented through the use of complex priority disciplines and require more computing power than in the OS of personal computers. The situation is similar with other functions. A network OS includes means of transmitting messages between computers over communication lines that are completely unnecessary in a standalone OS. Based on these messages, the network OS supports the sharing of computer resources between remote users connected to the network. To support message transfer functions, network operating systems contain special software components that implement popular communication protocols such as IP, IPX, Ethernet and others. Multiprocessor systems require a special organization from the operating system, with the help of which the operating system itself, as well as the applications it supports, can be executed in parallel by individual processors of the system. Parallel operation of individual parts of the OS creates additional problems for OS developers, since in this case it is much more difficult to ensure consistent access of individual processes to common system tables, to eliminate the effect of races and other undesirable consequences of asynchronous execution of work. Other requirements apply to cluster operating systems. A cluster is a loosely coupled collection of several computing systems that work together to run common applications and appear to the user as a single system. Along with special hardware, the functioning of cluster systems also requires software support from the operating system, which mainly comes down to synchronizing access to shared resources, fault detection and dynamic system reconfiguration. One of the first developments in the field of cluster technologies were solutions from Digital Equipment based on VAX computers. The company recently entered into an agreement with Microsoft Corporation to develop cluster technology using Windows NT. Several companies offer clusters based on UNIX machines. Along with OSes that are focused on a very specific type of hardware platform, there are operating systems that are specially designed so that they can be easily transferred from one type of computer to another type of computer, the so-called mobile OS. The most striking example of such an OS is the popular UNIX system. In these systems, hardware-dependent places are carefully localized, so that when the system is transferred to a new platform, only they are rewritten. A means to make it easier to port the rest of the OS is to write it in a machine-independent language, such as C, which was developed for programming operating systems. Features of areas of use Multitasking operating systems are divided into three types in accordance with the efficiency criteria used in their development: . batch processing systems (for example, OC EC), . time sharing systems (UNIX, VMS), . real-time systems (QNX, RT/11). Batch processing systems were intended to solve problems primarily of a computational nature that did not require quick results. The main goal and criterion for the effectiveness of batch processing systems is maximum throughput, that is, solving the maximum number of tasks per unit of time. To achieve this goal, batch processing systems use the following operating scheme: at the beginning of work, a batch of tasks is formed, each task contains a requirement for system resources; from this package of tasks a multiprogram mixture is formed, that is, many simultaneously performed tasks. For simultaneous execution, tasks are selected that have different resource requirements, so as to ensure a balanced load on all devices of the computer; for example, in a multiprogram mixture, the simultaneous presence of computational tasks and I/O-intensive tasks is desirable. Thus, the choice of a new task from a package of tasks depends on the internal situation in the system, that is, a “profitable” task is selected. Consequently, in such operating systems it is impossible to guarantee the completion of a particular task within a certain period of time. In batch processing systems, switching the processor from running one task to running another occurs only if the active task itself abandons the processor, for example, due to the need to perform an I/O operation. Therefore, a single task can occupy the processor for a long time, making it impossible to complete interactive tasks. Thus, the user’s interaction with the computer on which the batch processing system is installed boils down to the fact that he brings a task, gives it to the dispatcher-operator, and at the end of the day, after completing the entire batch of tasks, he receives the result. Obviously, this arrangement reduces the user's efficiency. Time-sharing systems are designed to correct the main drawback of batch processing systems - the isolation of the user-programmer from the process of performing his tasks. Each user of the time sharing system is provided with a terminal from which he can conduct a dialogue with his program. Since time-sharing systems allocate only a slice of CPU time to each task, no single task takes up the processor for very long, and response times are acceptable. If the quantum is chosen small enough, then all users simultaneously working on the same machine have the impression that each of them is solely using the machine. It is clear that time-sharing systems have lower throughput than batch processing systems, since each task launched by the user is accepted for execution, and not the one that is “beneficial” to the system, and, in addition, there is the overhead of computing power for more frequent switching processor from task to task. The criterion for the effectiveness of time sharing systems is not maximum throughput, but the convenience and efficiency of the user. Real-time systems are used to control various technical objects, such as a machine tool, a satellite, a scientific experimental installation, or technological processes , such as galvanic line, blast furnace process, etc. In all these cases, there is a maximum permissible time during which one or another program that controls the object must be executed, otherwise an accident may occur: the satellite will leave the visibility zone, experimental data coming from the sensors will be lost, the thickness of the galvanic coating will not will correspond to the norm. Thus, the efficiency criterion for real-time systems is their ability to withstand predetermined time intervals between launching a program and obtaining a result (control action). This time is called the reaction time of the system, and the corresponding property of the system is called reactivity. For these systems, a multi-program mixture is a fixed set of pre-developed programs, and the selection of a program for execution is carried out based on the current state of the object or in accordance with the schedule of planned work. Some operating systems can combine the properties of different types of systems, for example, some tasks can be performed in batch processing mode, and some in real time or in time-sharing mode. In such cases, batch processing mode is often called background mode. Features of construction methods When describing an operating system, the features of its structural organization and the basic concepts underlying it are often indicated. These basic concepts include: . Ways to build a system kernel - monolithic kernel or microkernel approach. Most operating systems use a monolithic kernel, which is compiled as a single program that runs in privileged mode and uses fast transitions from one procedure to another without requiring switching from privileged to user mode and vice versa. An alternative is to build an OS based on a microkernel, which also operates in privileged mode and performs only a minimum of hardware management functions, while higher-level OS functions are performed by specialized OS components - servers running in user mode. With this design, the OS works more slowly, since transitions between privileged mode and user mode are often performed, but the system turns out to be more flexible - its functions can be expanded, modified or narrowed by adding, modifying or excluding user mode servers. . Building an OS based on an object-oriented approach makes it possible to use all its advantages, which have proven themselves at the application level, within the operating system, namely: the accumulation of successful solutions in the form of standard objects, the ability to create new objects based on existing ones using the inheritance mechanism, good data protection due to their encapsulation in the internal structures of the object, which makes the data inaccessible for unauthorized use from the outside, the structuring of the system, consisting of a set of well-defined objects. unified service time, the use of a remote procedure call (RPC) mechanism for transparent distribution of software procedures across machines, multi-threaded processing, which allows you to parallelize calculations within a single task and perform this task on several network computers at once, as well as the presence of other distributed services. Network operating systems Structure of a network operating system A network operating system forms the basis of any computer network. Each computer on the network is largely autonomous, so under the network operating system in in a broad sense is understood as a set of operating systems of individual computers interacting for the purpose of exchanging messages and sharing resources according to uniform rules - protocols. In a narrow sense, a network OS is the operating system of a separate computer that provides it with the ability to work on a network. Rice. 1.1. Structure of a network OS In the network operating system of an individual machine, several parts can be distinguished (Figure 1.1): . Tools for managing local computer resources: functions for distributing RAM between processes, scheduling and dispatching processes, managing processors in multiprocessor machines, managing peripheral devices and other functions for managing local OS resources. ; maintaining directories of names of network resources; 3). The first network operating systems were a combination of an existing local operating system and a network shell built on top of it. At the same time, the minimum network functions necessary for the operation of the network shell, which performed the main network functions, were built into the local OS. An example of this approach is the use of the MS DOS operating system on each network machine (which, starting with its third version, has built-in functions such as file and record locking necessary for file sharing). The principle of building network operating systems in the form of a network shell over a local operating system is also used in modern operating systems, such as LANtastic or Personal Ware. . Means of providing own resources and services for general use - the server part of the OS (server). These tools provide, for example, file and record locking, which is necessary for their NT from Microsoft, which, due to the built-in network tools, provides higher performance and information security compared to the LAN Manager network OS from the same company (joint development with IBM), which is an add-on over the local OS/2 operating system. Peer-to-peer network OS and OS with dedicated servers Depending on how functions are distributed between network computers, network operating systems, and therefore networks, are divided into two classes: peer-to-peer and two-peer (Figure 1.4). The latter are more often called networks with dedicated servers. It is not customary to use a dedicated server as a computer to perform routine tasks not related to its main purpose, as this may reduce the performance of its work as a server. In connection with such considerations, the Novell NetWare OS does not provide the ability to run conventional application programs on the server side at all, that is, the server does not contain a client part, and there are no server components on workstations. However, in other network operating systems, functioning of the client part on a dedicated server is quite possible. For example, Windows NT Server can run regular local user programs that may require OS client functions to be executed when requests for resources from other computers on the network appear. In this case, workstations on which Windows NT Workstation is installed can perform the functions of a non-dedicated server. It is important to understand that despite the fact that in a network with a dedicated server, all computers in the general case can simultaneously perform the roles of both server and client, this network is not functionally symmetrical: in hardware and software, two types of computers are implemented in it - one, to a greater extent focused on performing server functions and running specialized server OSes, while others primarily perform client functions and run the OS version appropriate for this purpose. Functional asymmetry, as a rule, also causes asymmetry in the equipment - for dedicated servers, more powerful computers with large amounts of RAM and external memory are used. Thus, functional asymmetry in networks with a dedicated server is accompanied by asymmetry of operating systems (OS specialization) and hardware asymmetry (computer specialization). In peer-to-peer networks, all computers have equal access rights to each other's resources. Each user can, at his own discretion, declare any resource on his computer as shared, after which other users can exploit it. In such networks, all computers have the same OS installed, which provides all computers on the network with potentially equal capabilities. Peer-to-peer networks can be built, for example, on the basis of LANtastic, Personal Ware, Windows for Workgroup, Windows NT Workstation OS. In peer-to-peer networks, functional asymmetry may also arise: some users do not want to share their resources with others, and in this case, their computers act as a client; the administrator has assigned only functions for organizing the sharing of resources to other computers, which means they are servers; case when sharing does not object to the use of his resources and does not exclude the possibility of accessing other computers, the OS installed on his computer must include both server and client parts. Unlike networks with dedicated servers, in peer-to-peer networks there is no OS specialization depending on the predominant functional focus - client or server. All variations are implemented by configuring the same OS version. Peer-to-peer networks are easier to organize and operate, but they are used mainly to unite small groups of users who do not have great requirements for the volume of stored information, its security from unauthorized access and access speed. With increased requirements for these characteristics, two-rank networks are more suitable, where the server better solves the problem of serving users with its resources, since its equipment and network operating system are specially designed for this purpose. OS for workgroups and OS for enterprise networks Network operating systems have different properties depending on whether they are intended for large-scale networks working group (departmental), for campus networks or for enterprise networks. So, the next step in the evolution of networks is to combine the local networks of several departments into a single network of a building or group of buildings. Such networks are called campus networks. Campus networks can extend over several kilometers, but do not require wide-area connections. The operating system running on the campus network must provide employees in some departments with access to some files and resources on the networks of other departments. The services provided by campus network OSes go beyond simple file and printer sharing and often provide access to other types of servers, such as fax servers and high-speed modem servers. Important service What operating systems of this class provide is access to corporate databases, regardless of whether they are located on database servers or on minicomputers. It is at the campus network level that integration problems begin. In general, departments have already chosen the types of computers, networking equipment, and network operating systems. For example, the engineering department may use the UNIX operating system and Ethernet network equipment, the sales department may use the DOS/Novell operating environment and Token Ring equipment. Very often, a campus network connects disparate computer systems, while departmental networks use similar computers. The corporate network connects the networks of all departments of the enterprise, which are generally located at considerable distances. Corporate networks use WAN links to connect local networks or individual computers. Enterprise network users require all of the applications and services found on departmental and campus networks, plus some additional applications and services, such as access to mainframe and minicomputer applications and global communications. When an OS is designed for a local network or workgroup, its main responsibility is to share files and other network resources (usually printers) among locally connected users. This approach is not applicable at the enterprise level. Along with basic services related to the separation of files and printers, a network OS that is being developed for corporations must support a wider range of services, which usually includes mail service, teamwork tools, remote user support, fax service, voice message processing, video conferencing, etc. In addition, many existing methods and approaches to solving traditional problems of smaller-scale networks have proven unsuitable for the enterprise network. Tasks and problems came to the fore that were either of secondary importance or did not appear at all in the networks of work groups, departments, and even campuses. For example, the simplest task of maintaining user records for a small network has grown into a complex problem for an enterprise-scale network. And the use global connections requires enterprise operating systems to support protocols that work well on low-speed lines, and to abandon some traditionally used protocols (for example, those that actively use broadcast messages). The task of overcoming heterogeneity has acquired particular importance - numerous gateways have appeared on the network, ensuring the coordinated operation of various operating systems and network system applications. The following features may also be included in the characteristics of corporate operating systems. Application support. Enterprise networks run complex applications that require a lot of computing power to run. Such applications are divided into several parts, for example, on one computer the part of the application associated with executing queries to the database is executed, on the other - queries to the file service, and on client machines - the part that implements the application data processing logic and organizes the user interface. The computing part of the software systems shared by a corporation can be too voluminous and overwhelming for client workstations, so applications will run more efficiently if their most computationally complex parts are transferred to a powerful computer specially designed for this purpose - an application server. The application server must be based on a powerful hardware platform (multiprocessor systems, often based on RISC processors, specialized cluster architectures). The application server OS must provide high computing performance, and therefore support multithreaded processing, preemptive multitasking, multiprocessing, virtual memory and the most popular application environments (UNIX, Windows, MS-DOS, OS/2). In this regard, the NetWare network operating system can hardly be classified as a corporate product, since it lacks almost all the requirements for an application server. At the same time, the good support for universal applications in Windows NT actually allows it to claim a place in the world of corporate products. Help Desk. An enterprise OS must be able to store information about all users and resources in a way that can be managed from one central point. Like a large organization, a corporate network needs centralized storage of as complete background information as possible about itself (from data about users, servers, workstations to data about the cable system). It is natural to organize this information in the form of a database. Data from this database can be required by many network system applications, primarily management and administration systems. In addition, such a database is useful for organizing e-mail, group work systems, security services, network software and hardware inventory services, and for almost any large business application. A database that stores reference information provides the same variety of capabilities and poses the same many problems as any other large database. It allows you to carry out various search operations, sorting, modification, etc., which makes life very much easier for both administrators and users. But these conveniences come at the price of solving the problems of distribution, replication and synchronization. Ideally, network reference information should be implemented as a single database, and not be a set of databases specializing in storing information of one type or another, as is often the case in real operating systems. For example, Windows NT has at least five different types of help databases. The main domain directory (NT Domain Directory Service) stores information about users, which is used to organize their logical login to the network. Data about the same users may also be contained in another directory used by Microsoft Mail. Three more databases support low-level address resolution: WINS - matches Netbios names to IP addresses, the DNS directory - a domain name server - is useful when connecting an NT network to the Internet, and finally, the DHCP protocol directory is used to automatically assign IP addresses network computers. Closer to ideal are the directory services provided by Banyan (Streettalk III) and Novell (NetWare Directory Services), which offer a single directory for all network applications. The presence of a single help desk for a network operating system is one of the most important signs of its corporate character. Safety. Data security issues are of particular importance for the OS of a corporate network. On the one hand, in a large-scale network, there are objectively more opportunities for unauthorized access - due to the decentralization of data and the large distribution of “legitimate” access points, due to the large number of users whose trustworthiness is difficult to establish, and also due to the large number of possible points unauthorized connection to the network. On the other hand, enterprise business applications work with data that is vital to the success of the corporation as a whole. And to protect such data in corporate networks, along with various hardware, the entire range of protection tools provided by the operating system is used: selective or mandatory access rights, complex user authentication procedures, software encryption. | | system resources . The process management subsystem schedules the execution of processes, that is, it distributes processor time between several processes simultaneously existing in the system, and also deals with the creation and destruction of processes, provides processes with the necessary system resources, and supports interaction between processes. State of processes In a multitasking (multi-process) system, a process can be in one of three main states: EXECUTION - the active state of the process, during which the process has all the necessary resources and is directly executed by the processor; WAITING - the passive state of a process, the process is blocked, it cannot be executed for its own internal reasons, it is waiting for some event to occur, for example, the completion of an I/O operation, receiving a message from another process, or the release of some resource it needs; READY is also a passive state of the process, but in this case the process is blocked due to circumstances external to it: the process has all the resources required for it, it is ready to execute, but the processor is busy executing another process. During the life cycle, each process moves from one state to another in accordance with the process scheduling algorithm implemented in a given operating system. A typical process state graph is shown in Figure 2.1. In a single-processor system, there can be only one process in the RUNNING state, and in each of the WAITING and READY states there can be several processes; these processes form queues of waiting and ready processes, respectively. The life cycle of a process begins with the READY state, when the process is ready to execute and is waiting for its turn. When activated, the process goes into the RUNNING state and remains in it until it either releases the processor itself, going into the WAITING state for some event, or is forcibly “forced out” from the processor, for example, due to the exhaustion of the processor time quantum allocated to this process . In the latter case, the process returns to the READY state. The process transitions to this state from the WAITING state after the expected event occurs. The state of the operating environment is displayed by the state of the registers and program counter, processor operating mode, pointers to open files, information about unfinished I/O operations, error codes performed by this process system calls etc. This information is called process context. In addition, the operating system requires additional information to implement process scheduling: process identifier, process state, data on the degree of privilege of the process, location of the code segment and other information. In some operating systems (for example, UNIX), this kind of information, used by the OS to schedule processes, is called a process handle. The process descriptor, compared to the context, contains more operational information that should be easily accessible to the process scheduling subsystem. The process context contains less relevant information and is used by the operating system only after a decision has been made to resume the interrupted process. Process queues are handles to individual processes organized into lists. Thus, each descriptor, among other things, contains at least one pointer to another descriptor adjacent to it in the queue. This organization of queues makes it easy to reorder them, include and exclude processes, and transfer processes from one state to another. Program code will only begin to execute when a process is created for it by the operating system. To create a process means: 1. to create information structures that describe a given process, that is, its descriptor and context; the process ended and left the system. An error has occurred, . The process has entered the WAITING state. The CPU time allocated to this process has been exhausted. A process that has exhausted its quantum is transferred to the READY state and waits for a new quantum of processor time to be provided to it, and a new process is selected from the queue of ready ones for execution in accordance with a certain rule. This way, no process occupies the CPU for long, which is why quantization is widely used in time-sharing systems. The process state graph shown in Figure 2.1 corresponds to a quantization-based scheduling algorithm. Quanta allocated to processes can be the same for all processes or different. Quanta allocated to one process can be of a fixed value or vary at different periods of the process’s life. Processes that have not fully used the quantum allocated to them (for example, due to diverting I/O) may or may not receive compensation in the form of privileges on subsequent maintenance. The queue of ready processes can be organized in different ways: cyclically, according to the “first in, first out” (FIFO) rule or according to the “last in, first out” (LIFO) rule. Another group of algorithms uses the concept of "priority" of a process. Priority is a number characterizing the degree of privilege of a process when using computer resources, in particular, processor time: the higher the priority, the higher the privileges. The priority can be expressed as an integer or a fraction, a positive or negative value. The higher the privileges of a process, the less time it will spend in queues. The priority can be assigned directly by the system administrator depending on the importance of the work or the fee paid, or calculated by the OS itself according to certain rules; it can remain fixed throughout the life of the process or change over time in accordance with some law. In the latter case, the priorities are called dynamic. There are two types of priority algorithms: algorithms that use relative priorities and algorithms that use absolute priorities. In both cases, the selection of a process for execution from the ready queue is carried out in the same way: the process with the highest priority is selected. The problem of determining the moment of change of the active process is solved in different ways. In systems with relative priorities, the active process runs until it leaves the processor and enters the STANDBY state (either an error occurs or the process terminates). In systems with absolute priorities, the execution of the active process is interrupted under one more condition: if a process appears in the queue of ready processes whose priority is higher than the priority of the active process. In this case, the interrupted process goes into the ready state. Figure 2.2 shows process state graphs for algorithms with relative (a) and absolute (b) priorities. In many operating systems, scheduling algorithms are constructed using both quantization and priorities. For example, scheduling is based on quantization, but the quantum value and/or the order in which a process is selected from a queue of ready ones is determined by the priorities of the processes. With preemptive multitasking, the task scheduling mechanism is entirely located in the operating system, and the programmer writes his application without worrying about whether it will be executed in parallel with other tasks. In this case, the operating system performs the following functions: determines the moment when an active task is removed from execution, remembers its context, selects the next one from the queue of ready tasks and launches it for execution, loading its context. With non-preemptive multitasking, the scheduling mechanism is distributed between the system and application programs. The application program, having received control from the operating system, itself determines the moment of completion of its next iteration and transfers control to the OS using some system call, and the OS forms queues of tasks and selects the next task to complete in accordance with some algorithm (for example, taking into account priorities). performance. This mechanism creates problems for both users and developers. For users, this means that control of the system is lost for an arbitrary period of time, which is determined by the application (not the user). If an application spends too much time doing some work, such as formatting a disk, the user cannot switch from that task to another task, such as a text editor, while formatting continues in the background. This situation is undesirable because users usually do not want to wait long for the machine to complete its task. Therefore, application developers for non-preemptive operating environments, assuming the responsibility of the scheduler, must create applications so that they perform their tasks in small parts. For example, a format program can format one track of a floppy disk and return control to the system. After completing other tasks, the system will return control to the formatter to format the next track. This method of dividing time between tasks works, but it significantly complicates the development of programs and places increased demands on the programmer’s qualifications. The programmer must ensure that his program is "friendly" to other programs running simultaneously with it, giving control to them quite often. An extreme manifestation of an application's "unfriendliness" is its freezing, which leads to a general system crash. In systems with preemptive multitasking, such situations are usually excluded, since the central scheduling mechanism will remove the stuck task from execution. However, distributing scheduler functions between the system and applications is not always a disadvantage, and under certain conditions can be an advantage, because it allows the application developer to design the scheduling algorithm most suitable for a given fixed set of tasks. Since the developer himself determines in the program the moment in time when control is returned, this eliminates irrational interruptions of programs at “inconvenient” moments in time. In addition, data sharing problems are easily resolved: the task uses it exclusively during each iteration and is confident that no one else will change this data during this period. A significant advantage of non-preemptive systems is a higher speed of switching from task to task. Example effective use non-preemptive multitasking is the NetWare file server, which, largely due to this, has achieved high speed of execution of file operations. Less successful was the use of non-preemptive multitasking in the Windows 3.x operating environment. However, almost all modern operating systems focused on high-performance application execution (UNIX, Windows NT, OS/2, VAX/VMS) implement preemptive multitasking. IN Lately the turn has come to desktop-class operating systems, for example, OS/2 Warp and Windows 95. Perhaps in connection with this, preemptive multitasking is often called true multitasking. Process Synchronization and Communication The Synchronization Problem Processes often need to communicate with each other, for example, one process may pass data to another process, or multiple processes may process data from a shared file. In all these cases, the problem of process synchronization arises, which can be solved by suspending and activating processes, organizing queues, blocking and releasing resources. Rice. 2.3. An example of the need for synchronization Neglecting issues of synchronization of processes running in multiprogramming mode can lead to their incorrect operation or even system crash. Consider, for example (Figure 2.3), a file printing program (print server). This program prints in turn all the files, the names of which are sequentially, in the order in which they were received, recorded in a special public file of “orders” by other programs. The special variable NEXT, also available to all client processes, contains the number of the first free position for writing the file name of the “orders” file. Client processes read this variable, write the name of their file to the appropriate position in the “orders” file, and increase the NEXT value by one. Suppose that at some point the process R decided to print its file, for this it read the value of the NEXT variable, the value of which, for definiteness, is assumed to be equal to 4. The process remembered this value, but did not have time to place the file name, since its execution was interrupted (for example, due to quantum exhaustion). The next process S, wanting to print a file, read the same value of the NEXT variable, placed the name of its file in the fourth position and increased the value of the variable by one. When control is transferred to process R again, it will continue its execution in full accordance with the value of the current free position received during previous iteration , will also write the file name at position 4, over the file name of process S. Thus, process S will never see its file printed. The complexity of the synchronization problem lies in the irregularity of the situations that arise: in the previous example, another development of events can be imagined: the files of several processes were lost or, on the contrary, not a single file was lost. IN everything is determined by the mutual speeds of the processes and the moments of their interruption. Therefore, debugging interacting processes is challenging. Situations such as when two or more processes process shared data, and the final result depends on the ratio of the speeds of the processes, are called races. Critical section An important concept of process synchronization is the concept of a “critical section” of a program. The critical section is the part of the program in which shared data is accessed. To eliminate the effect of race conditions on a resource, it is necessary to ensure that at any time there is at most one process in the critical section associated with that resource. This technique is called mutual exclusion. The simplest way to enforce mutual exclusion is to allow the process in the critical section to disable all interrupts. However, this method is unsuitable because it is dangerous to trust a user process to control the system; it can occupy the processor for a long time, and if a process crashes in a critical area, the entire system will crash because interrupts will never be enabled. Another way is to use blocking variables. Each shared resource has a binary variable associated with it that takes the value 1 if the resource is free (that is, no process is currently in the critical section associated with that process) and the value 0 if the resource is busy. Figure 2.4 shows a fragment of a process algorithm that uses a blocking variable F(D) to implement mutual exclusion of access to a shared resource D. Before entering the critical section, the process checks whether resource D is free. If it is busy, then the check is repeated cyclically; if it is free, then the value of the variable F(D) is set to 0, and the process enters the critical section. After the process has completed all actions with the shared resource D, the value of the variable F(D) is again set to 1. Fig. 2.4. Implementing Critical Sections Using Blocking Variables If all processes are written using the conventions described above, then mutual exclusion is guaranteed. It should be noted that the operation of checking and setting a blocking variable must be indivisible. Let's explain this. Suppose that, as a result of checking a variable, the process determined that the resource was free, but immediately after that, without having time to set the variable to 0, it was interrupted. While it was suspended, another process occupied the resource, entered its critical section, but was also interrupted without completing work with the shared resource. When control was returned to the first process, it, considering the resource free, set the busy sign and began executing its critical section. Thus, the principle of mutual exclusion was violated, which could potentially lead to undesirable consequences. To avoid such situations, it is desirable to have a single “check-install” command in the machine’s command system, or to implement by system means the corresponding software primitives that would disable interrupts throughout the entire check and installation operation. Implementing critical sections using blocking variables has a significant disadvantage: during the time that one process is in the critical section, another process that requires the same resource will perform the routine task of polling the blocking variable, wasting processor time. To eliminate such situations, the so-called event apparatus can be used. This tool can be used to solve not only mutual exclusion problems, but also more general process synchronization problems. In different operating systems, the event apparatus is implemented in its own way, but in any case, system functions of a similar purpose are used, which we will conventionally call WAIT(x) and POST(x), where x is the identifier of some event. Figure 2.5 shows a fragment of a process algorithm that uses these functions. If the resource is busy, then the process does not perform a cyclic poll, but calls the WAIT(D) system function, here D denotes the event that resource D is released. The WAIT(D) function puts the active process in the WAITING state and makes a note in its descriptor that that the process is waiting for event D. The process that is currently using resource D, after exiting the critical section, executes the POST(D) system function, as a result of which the operating system scans the queue of waiting processes and puts the process waiting for event D into the READY state . A general means of synchronizing processes was proposed by Dijkstra, who introduced two new primitives. In abstract form, these primitives, denoted P and V, operate on non-negative integer variables called semaphores. Let S be such a semaphore. The operations are defined as follows: V(S) : the variable S is increased by 1 by one indivisible action; fetch, increment, and store cannot be interrupted, and S is not accessed by other processes while this operation is in progress. P(S) : Decreases S by 1 if possible. If S=0, then it is impossible to decrease S and remain in the region of non-negative integer values, in which case the process calling the P operation waits until this decrease becomes possible. Successfully checking and reducing is also an indivisible operation. If you rearrange the operations P(e) and P(b) in the “writer” program, then under some circumstances these two processes can mutually block each other. Indeed, let the "writer" be the first to enter the critical section and discover that there are no free buffers; it will start waiting for the “reader” to take the next record from the buffer, but the “reader” will not be able to do this, since for this it is necessary to enter the critical section, the entrance to which is blocked by the “writer” process. Let's look at another example of a dead end. Let two processes running in multiprogramming mode require two resources, for example, a printer and a disk, to complete their work. Figure 2.6a shows fragments of the corresponding programs. And suppose that after process A occupied the printer (set a blocking variable), it was interrupted. Control was given to process B, which first occupied the disk, but was blocked when the next command was executed, since the printer was already occupied by process A. Control was again received by process A, which, in accordance with its program, attempted to occupy the disk and was blocked: the disk was already allocated process B. Processes A and B can remain in this position for as long as desired. Depending on the ratio of process speeds, they can either use shared resources completely independently (d), or form queues for shared resources (c), or mutually block each other (b). Deadlock situations must be distinguished from in this case, although both occur when resources are shared and look similar in appearance: the process is suspended and waits for the resource to become free. However, a queue is a normal phenomenon, an inherent sign of high resource utilization when requests arrive randomly. It occurs when a resource is not available at the moment, but after some time it is released, and the process continues its execution. A deadlock, as its name suggests, is a somewhat unsolvable situation. Rice. 2.6. (a) fragments of programs A and B, separating the printer and the disk; (b) mutual blocking (clinch); (c) queue to the shared disk; (d) independent use of resources In the examples considered, the deadlock was formed by two processes, but more processes can mutually block each other. The deadlock problem includes the following tasks: . preventing deadlocks, . deadlock recognition, . restoring the system after deadlocks. Deadlocks can be prevented at the stage of writing programs, that is, programs must be written in such a way that a deadlock cannot occur under any ratio of the mutual speeds of the processes. So, if in the previous example process A and process B requested resources in the same sequence, then a deadlock would be impossible in principle. The second approach to preventing deadlocks is called dynamic and involves using certain rules when assigning resources to processes, for example, resources can be allocated in a certain sequence that is common to all processes. In some cases, when a deadlock occurs among many processes using many resources, recognizing the deadlock is a non-trivial task. There are formal, software-implemented methods for recognizing deadlocks, based on maintaining resource allocation tables and query tables for occupied resources. Analysis of these tables allows you to detect deadlocks. If a deadlock situation occurs, then it is not necessary to remove all blocked processes from execution. You can remove only part of them, which frees up resources expected by other processes, you can return some processes to the swap area, you can “rollback” some processes to the so-called checkpoint, which stores all the information necessary for recovery program execution s from this place. are placed in the program in places after which a deadlock may occur. From all of the above, it is clear that semaphores must be used very carefully, since one minor error can lead to a system shutdown. To make it easier to write correct programs, a high-level synchronization facility called a monitor was proposed. A monitor is a set of procedures, variables and data structures. Processes can call monitor procedures, but do not have access to the monitor's internal data. Monitors have an important property that makes them useful for achieving mutual exclusion: only one process can be active on a monitor. The compiler handles calls to monitor procedures in a special way. Typically, when a process calls a monitor procedure, the first few instructions in that procedure check to see if any other process is active on that monitor. If so, the calling process is suspended until another process frees the monitor. Thus, excluding multiple processes from entering the monitor is implemented not by the programmer, but by the compiler, which makes errors less likely. In distributed systems consisting of several processors, each of which has its own RAM, semaphores and monitors are unsuitable. In such systems, synchronization can only be achieved using messaging. For more information about this, see the section "Synchronization in Distributed Systems". Threads Multitasking is an essential feature of the OS. To support this property, the OS defines and designs for itself those internal units of work between which the processor and other computer resources will be divided. These internal units of work in different operating systems are different names - task, task, process, thread. In some cases, the entities denoted by these concepts are fundamentally different from each other. Speaking about processes, we noted that the operating system maintains their isolation: each process has its own virtual address space, each process is assigned its own resources - files, windows, semaphores, etc. Such isolation is necessary in order to protect one process from another, since they, sharing all the resources of the machine, compete with each other. In the general case, processes belong to different users sharing one computer, and the OS takes on the role of arbiter in disputes between processes for resources. Multiprogramming increases system throughput, but a single process can never be executed faster than if it were executed in single-program mode (any sharing of resources slows down the work of one of the participants due to the additional time spent waiting for the resource to become available). However, a task solved within a single process may have internal parallelism, which, in principle, makes it possible to speed up its solution. For example, during the execution of a task, an external device is accessed, and during this operation it is possible not to completely block the execution of the process, but to continue calculations along another “branch” of the process. For these purposes, modern operating systems offer the use of a relatively new multithreading mechanism. At the same time, a new concept of “thread” is introduced, and the concept of “process” significantly changes its meaning. Multiprogramming is now implemented at the thread level, and a task designed as several threads within a single process can be completed faster due to pseudo-parallel (or parallel in a multiprocessor system) execution of its individual parts. For example, if a spreadsheet was designed to be multi-threaded, the user could request a recalculation of their worksheet while continuing to populate the spreadsheet. Multi-threading can be used especially effectively to run distributed applications; for example, a multi-threaded server can simultaneously execute requests from several clients at once. Threads belonging to the same process are not as isolated from each other as processes in a traditional multitasking system, and it is easy to organize close communication between them. Indeed, unlike processes that belong to different, generally speaking, competing applications, all threads of one process always belong to one application, therefore the programmer writing this application can think in advance about the work of many threads of a process in such a way that they can interact, and not fight for resources. In traditional operating systems, the concept of "thread" is identical to the concept of "process". In reality, it is often desirable to have multiple threads sharing a single address space but executing quasi-parallel, making the threads process-like (minus the shared address space). Threads are sometimes called lightweight processes or mini-processes. Indeed, threads are similar to processes in many respects. Each thread runs strictly sequentially and has its own program counter and stack. Threads, like processes, can, for example, generate descendant threads and can move from state to state. Like traditional processes (that is, processes consisting of a single thread), threads can be in one of the following states: RUNNING, WAITING, and READY. While one thread is blocked, another thread in the same process can be running. Threads share the processor the way processes do, according to different scheduling options. However, different threads within a process are not as independent as separate processes. All such threads have the same address space. This means that they share the same global variables. Because each thread can access every virtual address, one thread can use another thread's stack. There is no complete protection between the threads, because, firstly, it is impossible, and secondly, it is not necessary. All threads of one process always solve the common problem of one user, and the threading apparatus is used here to solve the problem faster by parallelizing it. At the same time, it is very important for the programmer to have at his disposal convenient means of organizing the interaction of parts of one task. In addition to sharing the address space, all threads also share a set of open files, timers, signals, etc. So, the threads have their own: . program counter, . stack, . registers, . descendant threads, . state. The threads are separated: . address space, . global variables, . open files, . timers, . semaphores, . statistical information. Multi-thread processing improves system efficiency compared to multi-tasking processing. For example, in Windows multitasking, you can work with a spreadsheet and a word processor at the same time. However, if the user requests a recalculation of their worksheet, the spreadsheet is locked until this operation is completed, which can take a significant amount of time. In a multi-threaded environment, if the spreadsheet has been designed with multi-threaded processing capabilities provided to the programmer, this problem does not arise and the user always has access to the spreadsheet. Multi-thread processing is widely used in distributed systems. See the section "Processes and Threads in Distributed Systems" for more information. Some application tasks are easier to program using parallelism, such as writer-reader tasks in which one thread writes to a buffer and another reads from it. Since they share a common buffer, they should not be made into separate processes. Another example of using threads is to control signals such as keyboard interrupts (del or break). Instead of handling the interrupt signal, one thread is assigned to constantly wait for signals to arrive. Thus, using threads can reduce the need for user-level interrupts. In these examples, parallel execution is not as important as program clarity is. Finally, in multiprocessor systems, threads from the same address space can be executed in parallel on different processors. This is indeed one of the main ways to implement resource sharing in such systems. On the other hand, properly designed programs that use threads should run equally well on a single-processor machine in time-sharing mode between threads, and on a true multiprocessor. | | Virtual addresses are generated by a translator that translates the program into machine language. Since during translation, in the general case, it is not known where the program will be loaded into RAM, the translator assigns virtual (conditional) addresses to variables and commands, usually assuming by default that the program will be placed starting from address zero. The collection of virtual addresses of a process is called the virtual address space. Each process has its own virtual address space. Maximum size The virtual address space is limited by the address bit capacity inherent in a given computer architecture and, as a rule, does not coincide with the amount of physical memory available in the computer. This can be done manually by the operator during system startup or during its generation. The next task received for execution is placed either in a general queue (Figure 2.9a) or in a queue to a certain section (Figure 2.9b). loading a task into the partition allocated to it and adjusting the tables of free and occupied areas, . after completing the task, updating the tables of free and occupied areas. The code does not move during execution, meaning one-time address adjustments can be made through the use of a moving loader. The selection of a partition for a newly arrived task can be carried out according to different rules, such as, for example, “the first partition of sufficient size”, or “the partition with the smallest sufficient size”, or “the partition with the largest sufficient size”. All these rules have their advantages and disadvantages. Compared to the fixed partition method, this method has much greater flexibility, but it has a very serious drawback - memory fragmentation. Fragmentation is the presence of a large number of non-contiguous areas free memory very small size (fragments). So small that none of the newly arriving programs can fit into any of the sections, although the total size of the fragments can be significant, far exceeding the required amount of memory. Movable sections One of the methods to combat fragmentation is to move all occupied sections towards higher or lower addresses, so that all free memory forms a single free area (Figure 2.11). In addition to the functions that the OS performs when allocating memory into variable partitions, in this case it must also copy the contents of partitions from one memory location to another from time to time, adjusting the tables of free and occupied areas. This procedure is called "compression". Compression can be performed either every time a task is completed, or only when there is no free partition of sufficient size for a newly arrived task. In the first case, less computational work is required when adjusting tables, and in the second, the compression procedure is performed less frequently. Since programs move around RAM as they execute, address conversion from virtual to physical form must be done in a dynamic manner. The user writes programs as if he had a large, homogeneous RAM at his disposal, but in reality all the data used by the program is stored on one or more heterogeneous storage devices, usually disks, and, if necessary, partly mapped into real memory. Thus, virtual memory is a set of software and hardware that allows users to write programs whose size exceeds the available RAM; For this purpose, virtual memory solves the following problems: . places data in different types of storage devices, for example, part of the program in RAM, and part on disk; Rice. 2.12. Page memory allocation When the next process is activated, the address of the page table of this process is loaded into a special processor register. With each memory access, information about the virtual page that was accessed is read from the page table. If this virtual page is in RAM, then the virtual address is converted to a physical one. If the desired virtual page is currently paged out to disk, then a so-called page fault occurs. The running process is put into the waiting state and another process from the ready queue is activated. In parallel, the page fault processing program finds the required virtual page on disk and tries to load it into RAM. If there is a free physical page in memory, then the loading is performed immediately, but if there are no free pages, then the question is decided which page should be unloaded from RAM. In this situation, many different selection criteria can be used, the most popular of which are the following: . the longest unused page, . the first page that comes up, . the page that has had the least number of hits recently. Some systems use the concept of a working page set. The working set is defined for each process and is a list of the most frequently used pages that must reside in RAM and therefore cannot be paged out. After a page is selected that should leave RAM, its modification sign (from the page table) is analyzed. If the ejected page has been modified since loading, then its new version must be written to disk. If not, then it can simply be destroyed, that is, the corresponding physical page is declared free. Let's consider the mechanism for converting a virtual address into a physical one when organizing memory by page (Figure 2.13). A virtual address in paging can be represented as a pair (p, s), where p is the process virtual page number (page numbering starts from 0), and s is the offset within the virtual page. Given that the page size is 2 to the power of k, the offset s can be obtained by simply stripping off the k least significant bits in the binary representation of the virtual address. The remaining most significant bits represent the binary representation of the page number p. Rice. 2.13. The mechanism for converting a virtual address into a physical one when paging memory When each access to RAM by hardware, the following actions are performed: 1. based on the starting address of the page table (the contents of the page table address register), the virtual page number (the most significant bits of the virtual address) and the record length in the page table (system constant), the address of the desired entry in the table is determined, 2. the physical page number is extracted from this entry, 3. an offset (low order bits of the virtual address) is added to the physical page number. Using in point (3) the fact that the page size is a power of 2 allows us to use the concatenation (attachment) operation instead of the longer addition operation, which reduces the time it takes to obtain a physical address, and therefore increases computer performance. The performance of a paged memory system is affected by the time required to process page interrupts and convert virtual addresses to physical addresses. If page faults occur frequently, the system may waste most of its time swapping pages. To reduce the frequency of page faults, the page size would have to be increased. In addition, increasing the page size reduces the size of the page table, and therefore reduces memory costs. On the other hand, if the page is large, then the dummy area in the last virtual page of each program is large. On average, each program loses half the volume of a page, which can add up to a significant amount if the page is large. The time it takes to convert a virtual address to a physical address is largely determined by the page table access time. In this regard, they tend to place the page table in “fast” storage devices. This could be, for example, a set of special registers or memory that is used to reduce access time associative search and data caching. Page memory allocation can be implemented in a simplified version, without dumping pages to disk. In this case, all virtual pages of all processes are constantly in RAM. This paging option, although it does not provide the user with virtual memory, almost eliminates fragmentation due to the fact that the program can be loaded into non-contiguous areas, and also because there is never any leftovers when loading virtual pages. Segmented distribution With paging, the virtual address space of a process is mechanically divided into equal parts. This does not allow differentiation of methods of access to different parts of the program (segments), and this property is often very useful. For example, you can prohibit write and read operations in the code segment of the program, and allow read-only for the data segment. In addition, breaking the program into “meaningful” parts makes it fundamentally possible for several processes to share one segment. For example, if two processes use the same math routine, then only one copy of that routine can be loaded into RAM. Let's consider how segmented memory allocation implements these capabilities (Figure 2.14). The process's virtual address space is divided into segments, the size of which is determined by the programmer taking into account the semantic meaning of the information contained in them. A single segment can be a subroutine, an array of data, etc. Sometimes program segmentation is done by default by the compiler. When a process loads, some of the segments are placed in RAM (and for each of these segments, the operating system looks for a suitable area of ​​free memory), and some of the segments are placed in disk memory. Segments of one program can occupy non-contiguous areas in RAM. During boot, the system creates a table of process segments (similar to a page table), in which for each segment the starting physical address of the segment in RAM, segment size, access rules, modification sign, sign of access to this segment in the last time interval and some other information are indicated. . If the virtual address spaces of several processes include the same segment, then in the segment tables of these processes references are made to the same section of RAM into which this segment is loaded in a single copy. Rice. 2.14. Memory allocation by segments A system with a segment organization functions similarly to a system with a page organization: interruptions occur from time to time due to the lack of necessary segments in memory, when it is necessary to free up memory, some segments are unloaded, and with each access to RAM, a virtual address is converted to a physical one. In addition, when accessing memory, it is checked whether access of the required type to this segment is allowed. A virtual address in a segmented memory organization can be represented by a pair (g, s), where g is the segment number, and s is the offset in the segment. The physical address is obtained by adding the starting physical address of the segment, found in the segment table at number g, and the offset s. The disadvantage of this method of memory allocation is fragmentation at the segment level and slower address translation compared to page organization. Page-segment allocation As the name suggests, this method is a combination of page and segment memory allocation and, as a result, combines the advantages of both approaches. The virtual space of a process is divided into segments, and each segment in turn is divided into virtual pages, which are numbered within the segment. RAM is divided into physical pages . The process is loaded by the operating system page by page, with some pages located in RAM and some on disk. For each segment, its own page table is created, the structure of which is completely identical to the structure of the page table used in paging. For each process, a segment table is created, which indicates the addresses of page tables for all segments of this process. The segment table address is loaded into a special processor register when the corresponding process is activated. Figure 2.15 shows the virtual-to-physical address conversion diagram for this method. Various types super-RAM and RAM, disks, tapes), differing in average access time and cost of data storage per bit (Figure 2.17). The user would like to have both inexpensive and fast memory. Cache memory provides a compromise solution to this problem. Rice. 2.17. Storage hierarchy Cache memory is a way of organizing the joint functioning of two types of storage devices that differ in access time and data storage cost, which allows you to reduce the average data access time by dynamically copying the most frequently used information from the “slow” storage into the “fast” storage . Cache memory is often called not only a way to organize the operation of two types of storage devices, but also one of the devices is “fast” memory. It is more expensive and, as a rule, has a relatively small volume. It is important that the cache mechanism is transparent to the user, who does not have to provide any information about the intensity of data usage and does not have to participate in any way in moving data from one type of storage to another type of storage, all this is done automatically by system tools. Let's consider a special case of using cache memory to reduce the average access time to data stored in RAM. To do this, a fast memory, simply called cache memory, is placed between the processor and RAM (Figure 2.18). As such, for example, associative memory can be used. The contents of the cache memory are a collection of records of all data elements loaded into it. Each data item entry includes the address that the data item has in main memory, and control information : a sign of modification and a sign of accessing data for some recent period of time.: 1. The contents of the cache memory are viewed to determine whether the desired data is in the cache memory; The cache memory is not addressable, so the search for the necessary data is carried out by the content - the value of the "address in RAM" field taken from the request.

2. If data is found in the cache, it is read from it and the result is sent to the processor.

3. If the necessary data is not available, then it, along with its address, is copied from RAM to cache memory, and the result of the request is transmitted to the processor. When copying data, it may turn out that there is no free space in the cache memory, then the data that has had the least number of accesses in the last period is selected for eviction from the cache memory. If the evicted data has been modified while in cache memory, it is rewritten to RAM. If this data has not been modified, then its place in the cache memory is declared free. In practice, not just one accessed data element is read into the cache memory, but an entire block of data; this increases the probability of a so-called “cache hit,” that is, finding the required data in the cache memory. Let us show how the average data access time depends on the probability of hitting the cache. Let there be a main storage device with an average data access time t1 and a cache memory with an access time t2, it is obvious that t2, 7.1. Basic operating system concepts

One of the components of computer science is - software (software) which is heterogeneous and has a complex structure, including several levels: system, service, instrumental, application. At the lowest level there are complexes of programs that perform interface functions (intermediary between a person and a computer, hardware and software, between simultaneously running programs) of distributing various computer resources. Programs at this level are called

systemic. Any user programs are launched under the control of software complexes called operating systems. Programs at this level are called utilities and perform various auxiliary functions. These can be diagnostic programs used when servicing various devices (floppy and hard disk), test programs representing a set of maintenance programs, archivers, antiviruses, etc. Utilities typically run under the operating system (although they may also access hardware directly), so they are considered a higher level. In some classifications, system and service levels are combined into one class - system software.

Instrumentation software presents software packages for creating other programs. The process of creating new programs in machine command language is very complex and laborious, so it is low-performance. In practice, most programs are compiled in formal programming languages, which are closer to mathematical ones, therefore easier and more productive to work with, and the translation of programs into machine code language is carried out by a computer through instrumental software. Tool software programs are controlled by system programs, so they are at a higher level.

Application software- the largest class of programs in terms of volume are programs end user. There are about six thousand different professions in the world, thousands of different hobbies, and most of them currently have some kind of application software products. Application software is also controlled by system programs and is at a higher level.

Summarizing the above, we can propose the following software structure (Fig. 7.1).

Fig.7.1. Software classification



The proposed classification of software is largely arbitrary, since currently the software products of many companies have begun to combine software elements from different classes. For example, the Windows operating system, being a complex of system programs, contains a block of utility programs (defragmentation, scanning, disk cleanup, etc.), as well as the word processor WordPad, the graphic editor Paint, which belong to the class of application programs.

The central place in the software structure is occupied by the operating system (OS). It is “a system of programs designed to provide a certain level of efficiency to a digital computing system by automated control its work and the range of services provided to users.”

An operating system is a basic set of computer programs that provides a user interface, control of computer hardware, working with files, input and output of data, as well as execution of application programs and utilities.

The OS allows you to abstract away from hardware implementation details, providing software developers with minimal necessary set functions. From the point of view of ordinary people, ordinary users of computer equipment, the OS also includes user interface programs.

Operating system - a program that loads when the computer is turned on. It carries out a dialogue with the user, manages the computer, its resources (RAM, disk space, etc.), and launches other application programs for execution. The operating system provides the user and application programs with convenient way communication (interface) with personal computer devices.

The most common operating systems: MS-DOS, OS/2, UNIX, WINDOWS, LINUX, WINDOWS NT, they have different modifications.

Main functions (simple OS):

Standardized access to peripheral devices (input/output devices);

RAM management (distribution between processes, virtual memory);

Controlling access to data on non-volatile media (such as a hard drive, CD, etc.), usually using a file system;

User interface;

Network operations, protocol stack support

Additional functions:

Parallel or pseudo-parallel execution of tasks (multitasking);

Interaction between processes: data exchange, mutual synchronization;

Protecting the system itself, as well as user data and programs from malicious actions of users or applications;

Differentiation of access rights and multi-user mode of operation (authentication, authorization).

A program that hides the truth about the hardware and presents a simple list of files that can be read and written, i.e. ., The operating system not only eliminates the need to work directly with disks and provides a simple, file-oriented interface, but also hides a lot of unpleasant work with interrupts, time counters, memory organization and other low-level elements. In each case, the procedure provided by the OS is much simpler and easier to use than the actions required by the underlying hardware.

From the user's point of view, the OS performs the function of a virtual machine, which is simpler and easier to work with than directly with the hardware that makes up the real computer, and for programs, the OS provides a number of capabilities that they can use using special teams, called system calls.

The concept of viewing the OS primarily as a user-friendly interface is a top-down view. An alternative bottom-up view gives an idea of ​​the OS as a mechanism for controlling all parts of the computer. Modern computers consist of processors, memory, disks, networking equipment, printers and a huge number of other devices. In the second approach, the OS's job is to provide an organized and controlled distribution of processors, memory, and I/O devices among the various programs competing to use them.

Types of operating systems.

The history of OS development goes back many years. Operating systems appeared and developed in the process of improving computer hardware, so these events are historically closely related. The development of computers has led to the emergence of a huge number of different operating systems, not all of which are widely known.

At the top level are OS for mainframes. These huge machines can still be found in large organizations. Mainframes differ from personal computers in their input/output capabilities. Mainframes with thousands of disks and terabytes of data are quite common. Mainframes act as powerful web servers and servers for large enterprises and corporations. Mainframe operating systems are primarily designed to handle multiple simultaneous jobs, most of which require great amount I/O operations. They typically perform three types of operations: batch processing, transaction processing ( group operations) and time sharing. Batch processing performs standard tasks for users working in interactive mode. Transaction processing systems manage very large numbers of requests, such as airline reservations. Each individual request is small, but the system must respond to hundreds and thousands of requests per second. Time-sharing systems allow many remote users to simultaneously perform their tasks on one machine, for example, working with a large database. All of these functions are closely related, and the mainframe operating system performs them all. An example of a mainframe operating system is OS/390.

One level below are server OS. Servers are either multiprocessor computers or even mainframes. These operating systems simultaneously serve many users and allow them to share software and hardware resources among themselves. Servers also provide the ability to work with printing devices, files, or the Internet. Internet providers typically operate multiple servers in order to support simultaneous network access for multiple clients. Servers store website pages and process incoming requests. UNIX and Windows 2000 are typical server operating systems. Now the Linux operating system has also begun to be used for this purpose.

The next category consists of OS for personal computers. Their job is to provide a user-friendly interface for a single user. Such systems are widely used in everyday work. The main operating systems in this category are the Windows platform, Linux and the Macintosh computer operating system.

Another type of OS is real time systems. The main parameter of such systems is time. For example, in manufacturing control systems, real-time computers collect industrial process data and use it to control equipment. Such processes must meet strict time requirements. If, for example, a car moves along a conveyor belt, then each action must be carried out at a strictly defined point in time. If a welding robot welds a seam too early or too late, it will cause irreparable damage to the product. VxWorks and QNX systems are real-time operating systems.

Embedded operating systems used in pocket computers and household appliances. A PDA is a small computer that fits in your pocket and performs a small set of functions, such as a phone book and a notepad. Embedded systems that control the operation of household appliances are not considered computers, but have the same characteristics as real-time systems, but have special size, memory, and power limitations that make them a class of their own. Examples of such operating systems are PalmOS and Windows CE (Consumer Electronics).

The smallest operating systems run on smart cards, which is a device the size of credit card and containing a central processor. Such operating systems are subject to very strict restrictions on processor power and memory. Some of them can handle only one transaction, such as electronic payment, but other OSes perform more complex functions.

Classification of operating systems.

Operating systems are classified by:

Number of concurrent users: single-user, multi-user;

The number of processes simultaneously running under the control of the system: single-task, multi-task;

Number of supported processors: single-processor, multi-processor;

OS code bits: 8-bit, 16-bit, 32-bit, 64-bit;

Interface type: command (text) and object-oriented (graphical);

Type of user access to the computer: batch processing, time sharing, real time;

Type of resource use: network, local.

In accordance with the first sign of classification, multi-user operating systems, unlike single-user operating systems, support the simultaneous operation of several users on a computer at different terminals.

The second sign involves dividing the OS into multi-tasking and single-tasking. The concept of multitasking means supporting the parallel execution of several programs existing within the same computer system at one point in time. Single-tasking operating systems support the execution mode of only one program at a time.

In accordance with the third feature, multiprocessor operating systems, unlike uniprocessor operating systems, support the mode of distributing the resources of several processors to solve a particular task.

The fourth sign divides operating systems into 8-, 16-, 32- and 64-bit. This implies that the bit capacity of the operating system cannot exceed the bit capacity of the processor.

In accordance with the fifth characteristic, operating systems are divided by type of user interface into object-oriented (usually with a graphical interface) and command-based (with a text-based interface). According to the sixth characteristic, operating systems are divided into systems:

Batch processing, in which a package (set) of tasks is formed from programs to be executed, entered into the computer and executed in order of priority, with possible consideration of priority;

Time sharing (TSR), providing simultaneous dialog (interactive) mode of access to the computer of several users on different terminals, which are allocated machine resources in turn, which is coordinated by the operating system in accordance with a given service discipline;

Real time, providing a certain guaranteed time for the machine to respond to a user request with its control by any events, processes or objects external to the computer.

In accordance with the seventh classification criterion, operating systems are divided into network and local. Network operating systems are designed to manage the resources of computers connected to a network for the purpose of sharing data, and provide powerful means of restricting access to data to ensure their integrity and safety, as well as many service capabilities for using network resources.

In most cases, network operating systems are installed on one or more fairly powerful server computers dedicated solely to maintaining the network and shared resources. All other operating systems will be considered local and can be used on any personal computer, as well as on a separate computer connected to the network as a workstation or client.

OS software components provide computing management and implement functions such as resource planning and distribution, information input/output management, and data management. The volume of the OS and the number of its component programs are largely determined by the type of computer used, the complexity of the operating modes of the computer and computer, the composition of the technical means, etc. Using the OS allows you to:

Increasing computer capacity, i.e. an increase in the total amount of work performed by a computer per unit of time;

Reducing system response time, i.e. reducing the time interval between the moments when tasks are received in the computer and the time when results are received;

Monitoring the performance of hardware and software;

Assisting users and operators in their use of hardware and software, ensuring their operation;

Managing programs and data during calculations;

Ensuring the adaptation of the computer, its structural flexibility, which consists in the ability to change and be replenished with new hardware and software.

The operating system is a complex of system and utility software. On the one hand, it relies on the basic computer software included in its BIOS system ( basic system input-output); on the other hand, it itself is the support for software at higher levels - application and most service applications. Operating system applications are usually called programs designed to work under the control of this system.

The main function of all operating systems is mediation. It consists of providing several types of interface:

Interface between the user and the computer hardware (user interface);

Interface between software and hardware (hardware-software interface);

Interface between different types of software (software interface).

Even for one hardware platform, such as the IBM PC, there are several operating systems. The differences between them are considered in two categories: internal and external. Internal differences are characterized by methods of implementing basic functions. External differences are determined by the availability and accessibility of applications of a given system necessary to meet the technical requirements for a specific workplace.

The main criteria for the approach to choosing an operating system:

Currently available a large number of operating systems, and the user is faced with the task of determining which operating system is better than others (according to certain criteria). Obviously, there are no ideal systems; each of them has its own advantages and disadvantages. When choosing an operating system, the user must imagine how this or that OS will provide him with a solution to his problems.

To choose one or another OS, you need to know:

On what hardware platforms and at what speed does the OS run;

What peripheral hardware does the OS support;

How fully does the OS satisfy the user’s needs, that is, what are the functions of the system;

What is the way the OS interacts with the user, that is, how visual, convenient, understandable and familiar the interface is to the user;

Are there informative tips, built-in reference books, etc.;

What is the reliability of the system, that is, its resistance to user errors, equipment failures, etc.;

What capabilities does the OS provide for organizing networks?

Does the OS provide compatibility with other operating systems;

What tools does the OS have for developing application programs?

Does the OS support various national languages?

What known application software packages can be used when working with this system;

How the OS protects information and the system itself.

Operating systems basics. Lecture course. Karpov V.E., Konkov K.A.

M.: Internet University of Information Technologies, 2005. - 536 p.

The book is a systematic training course on the theory of operating systems. It examines the fundamental principles of construction and design features of modern operating systems. The theoretical material is supplemented with a variety of practical examples. Recommended for students of higher educational institutions studying specialties in the field of information technology.

Format: pdf

Size: 5.6MB

Download: drive.google

Content
Part I. Review 13
Lecture 1. Introduction 13
What is an operating system 13
A Brief History of the Evolution of Computing Systems 16
Basic concepts, OS 24 concepts
Architectural features of OS 27
OS classification 32
Conclusion 34
Part II. Processes and their support in the operating system 41
Lecture 2. Processes 41
Process concept 41
Process states 43
Process operations and related concepts 46
Conclusion 54
Lecture 3. Process planning 59
Planning levels 59
Planning criteria and requirements for algorithms 61
Planning options 62
Preemptive and non-preemptive scheduling 64
Planning algorithms 65
Conclusion 82
Lecture 4. Process cooperation and main aspects of its logical organization 87
Communicating Processes 87
Categories of information exchange media 89
Logical organization of the information transfer mechanism 90
Performance threads 96
Conclusion 100
Lecture 5. Synchronization algorithms 105
Interleaving, race condition and mutual exclusions 105
Critical section 108
Software algorithms for organizing the interaction of processes 111
Hardware support for mutual exclusions 117
Conclusion 119
Lecture 6. Synchronization mechanisms 123
Semaphores 123
Monitors 126
Messages 129
Equivalence of semaphores, monitors and messages 130
Conclusion 133
Lecture 7. Dead ends 141
Introduction 141
Conditions for deadlocks 143
The main directions of the fight against dead ends 143
Ignoring the Deadlock Problem 144
Ways to prevent deadlocks 144
Deadlock Detection 149
Recovery from deadlocks 150
Conclusion 151
Part III. Memory management 155
Lecture 8. Organization of computer memory. The simplest memory management schemes 155
Introduction 155
The simplest memory management schemes 161
Page memory 166
Segment and segment-page memory organization 168
Conclusion 171
Lecture 9. Virtual memory. Architectural support for virtual memory 175
The concept of virtual memory 175
Architectural support for virtual memory 177
Conclusion 185
Lecture 10. Hardware-independent virtual memory management level 189
Exceptional situations when working with memory 189
Page Memory Management Strategies 190
Page replacement algorithms 191
Controlling the number of pages allocated to a process. Working set model 197
Page demons 200
Software support for the segmented process memory model.. 201
Certain aspects of the functioning of the memory manager.... 203
Conclusion 205
Part IV. File systems 209
Lecture 11. Files from the user's point of view 209
Introduction 209
General information about files 212
Organizing and accessing files 214
File operations 217
Directories. Logical structure file archive 218
Operations on directories 222
File protection 223
Conclusion 224
Lecture 12. Implementing a file system 229
General File System Structure 229
External memory management 232
Implementation of directories 240
Mounting file systems 243
Linking files 245
Process cooperation when working with files 247
File system reliability 250
File system performance 254
Implementation of some operations on files 256
Modern file system architectures 259
Conclusion 260
Part V. I/O 265
Lecture 13: I/O Control System 265
Physical principles of input-output organization 266
Logical principles of input-output organization 276
Algorithms for scheduling requests to a hard disk 286
Conclusion 291
Part VI. Networks and network operating systems 295
Lecture 14. Networks and network operating systems 295
Why are computers connected in networks 296
Network and distributed operating systems 297
Interaction of remote processes as the basis for the operation of computer networks 298
Basic issues of logical organization of information transfer between remote processes 301
Understanding the 302 protocol
Multi-level model for constructing networked computing systems 304
Network addressing problems 308
Routing problems in networks 315
Connection Communication and Data Transfer Using 318 Messages
Synchronizing remote processes 320
Conclusion 320
Part VII. Operating system security issues 325
Lecture 15. Basic concepts of information security 325
Introduction 325
Security Threats 327
Formalization of the approach to ensuring information security 329
Cryptography as one of the basic security technologies of OS 331
Conclusion 335
Lecture 16. Security mechanisms of operating systems 339
Identification and Authentication 339
Authorization. Restricting access to OS objects 342
Intrusion detection. Security system audit 347
Analysis of some popular operating systems from the point of view of their security 348
Conclusion 353
Seminars 357
Seminars 1-2. Introduction to the practical training course. Introduction to the UNIX Operating System 357
Seminars 3-4. Processes in the UNIX 385 operating system
Seminar 5. Organizing process interaction via pipe and FIFO in UNIX 403
Seminars 6-7. System V IPC Tools. Organization of work with shared memory in UNIX. The concept of threads 431
Seminar 8. Semaphores in UNIX as a means of synchronizing processes 465
Workshop 9: Message Queues in UNIX 479
Seminars 10-11. File system organization in UNIX. Working with files and directories. Understanding memory mapped files 501
Seminars 12-13. Organization of input-output in UNIX. Device files. Interrupt device. Signals in UNIX 539
Seminars 14-15. TCP/IP protocol family. Sockets in UNIX and the basics of working with them 575
Literature 627

Operating system (OS) is a program that provides the ability to rationally use computer equipment in a user-friendly manner. The introductory lecture introduces the subject studied in this course. First we will try to answer the question, what is OS First we will try to answer the question, what is. This will be followed by an analysis of the evolution First we will try to answer the question, what is and a story about the emergence of the basic concepts and components of modern First we will try to answer the question, what is. Finally, a classification will be presented

from the point of view of architectural features and use of computer resources.

What is an operating system

What does any computing system consist of? Firstly, from what in English-speaking countries is usually called the word hardware, or technical support: CPU, memory, monitor, disk devices, etc., united by a backbone connection called a bus. Some information about computer architecture is available in Appendix 1 to this lecture.

Secondly, a computing system consists of software. All software is usually divided into two parts: application and system. Application software usually includes a variety of banking and other business programs, games, word processors, etc. System software usually refers to programs that facilitate the operation and development of application programs. It must be said that the division into application and system software is partly arbitrary and depends on who makes the division. Thus, an ordinary user, inexperienced in programming, may consider Microsoft Word to be a system program, but, from the programmer’s point of view, it is an application. The C language compiler for an ordinary programmer is a system program, and for a system programmer it is an application program. Despite this fuzzy edge, this situation can be displayed as a sequence of layers (see Fig. 1.1), highlighting separately the most common part of the system software - the operating system:

Rice. 1.1. Layers of computer system software

What is OS

Most users have operating experience operating systems, but nevertheless they will find it difficult to give this concept an exact definition. Let's take a quick look at the main points of view.

Operating system as a virtual machine

During development First we will try to answer the question, what is Abstraction is widely used, which is an important method of simplification and allows you to concentrate on the interaction of high-level components of the system, ignoring the details of their implementation. In this sense First we will try to answer the question, what is represents the interface between the user and the computer.

The architecture of most computers at the machine instruction level is very inconvenient for use by application programs. For example, working with a disk requires knowledge of the internal structure of its electronic component - a controller for entering commands, searching and formatting tracks, reading and writing sectors, etc. It is clear that the average programmer is not able to take into account all the features of the equipment (in modern terminology, develop device drivers), but must have a simple high-level abstraction, say, representing the information space disk as a set of files. The file can be opened for reading or writing, used to retrieve or reset information, and then closed. This is conceptually simpler than worrying about the details of moving disk heads or organizing the operation of a motor. Similarly, with the help of simple and clear abstractions, all unnecessary details of the organization are hidden from the programmer, interrupts timer operation , memory management, etc. Moreover, on modern computing systems you can create the illusion of unlimited RAM size and number processors . Does all this operating system . Does all this . Thus, appears to the user virtual machine

, which is easier to deal with than directly with the computer hardware.

Operating system as resource manager Operating system Operating system as resource manager designed to control all parts of a highly complex computer architecture. Consider, for example, what would happen if several programs running on the same computer tried to output to a printer at the same time. We would end up with a jumble of lines and pages produced by different programs. . Does all this prevents this kind of chaos by buffering printable information on disk and queuing it for printing. For multi-user computers, the need to manage and protect resources is even more obvious. Hence,, How , memory management, etc. Moreover, on modern computing systems you can create the illusion of unlimited RAM size and number resource manager

, carries out an orderly and controlled distribution

, memory and other resources between different programs. The operating system as a protector of users and programs as an organizer of safe operation of users and their programs. From this point of view The operating system as a protector of users and programs appears to be a state security system, which is entrusted with police and counterintelligence functions.

Operating system as a constantly running kernel

Finally, we can give the following definition: The operating system as a protector of users and programs is a program that constantly runs on a computer and interacts with all application programs. It would seem that this is an absolutely correct definition, but, as we will see later, in many modern operating systems Only a part works constantly on the computer operating system

, which is usually called its core. . Does all this As we can see, there are many points of view on what it is . Does all this. It is impossible to give it an adequate strict definition. It’s easier for us to say not what to eat

, and why it is needed and what it does. To clarify this issue, consider the history of the development of computing systems.

A Brief History of the Evolution of Computing Systems We will consider the history of the development of computing, and not operating systems

because hardware and software have evolved together, influencing each other. The emergence of new technical capabilities led to a breakthrough in the creation of convenient, effective and safe programs, and fresh ideas in the software field stimulated the search for new technical solutions. It was these criteria - convenience, efficiency and security - that played the role of natural selection factors in the evolution of computing systems.

First period (1945–1955). Lamp machines.

No operating systems We will begin our study of the development of computer systems with the advent of electronic computing systems (omitting the history of mechanical and electromechanical devices). The first steps in the development of electronic computers were taken at the end of the Second World War. In the mid-40s, the first tube computing devices were created and operating systems there was no question, all tasks of organizing the computing process were solved manually by each programmer from the control panel. Only one user could be at the remote control. The program was loaded into the machine's memory at best case scenario

from a deck of punched cards, and usually using a switch panel.

The computing system performed only one operation at a time (input-output or actual calculations). Debugging of programs was carried out from the control panel by studying the state of the memory and registers of the machine. At the end of this period, the first system software appears: in 1951–1952. prototypes of the first compilers from symbolic languages ​​(Fortran, etc.) appeared, and in 1954 Nat Rochester developed an assembler for the IBM-701.

A significant portion of the time was spent preparing to launch the program, and the programs themselves were executed strictly sequentially.

This mode of operation is called sequential data processing. In general, the first period is characterized by the extremely high cost of computing systems, their small number and low efficiency of use. Second period (1955–early 60s). Transistor-based computers. Batch Operating Systems Since the mid-50s, the next period in the evolution of computer technology began, associated with the emergence of a new technical base - semiconductor elements. Application

The process of running programs itself changes. Now the user brings the program with input data in the form of a deck of punched cards and indicates the necessary resources. This deck is called a task. The operator loads the task into the machine's memory and starts it for execution. The resulting output data is printed on the printer, and the user receives it back after some (quite long) time.

Changing the requested resources causes program execution to be suspended, as a result CPU often idle. To improve the efficiency of computer use, jobs with similar resources begin to be collected together, creating a batch of jobs.

The first ones appear batch processing systems , which simply automate the launch of one program from a package after another and thereby increase the load factor processor. When implementing batch processing systems a formalized task control language was developed, with the help of which the programmer informed the system and the operator what work he wanted to perform on the computer. Batch Processing Systems became the prototype of modern We will consider the history of the development of computing, and not, they were the first system programs designed to control the computing process.

Third period (early 60s - 1980). Computers based on integrated circuits.

The first multitasking OS In general, the first period is characterized by the extremely high cost of computing systems, their small number and low efficiency of use. The next important period in the development of computers dates back to the early 60s - 1980. At this time, the technical base underwent a transition from individual semiconductor elements of the type To integrated circuits , memory management, etc. Moreover, on modern computing systems you can create the illusion of unlimited RAM size and number.

Increasing the efficiency of using processor time is hampered by the low speed of mechanical input-output devices (a fast punched card reader could process 1200 punched cards per minute, printers printed up to 600 lines per minute). Instead of directly reading a package of tasks from punched cards into memory, they begin to use its preliminary recording, first on magnetic tape, and then on disk. When data input is required during a job, it is read from disk. Similarly, output information is first copied to the system buffer and written to tape or disk, and printed only after the job is completed. In the beginning, actual I/O operations were carried out off-line, that is, using other, simpler, free-standing computers. Subsequently, they begin to be executed on the same computer that performs the calculations, that is, in on-line mode. This technique is called spooling (short for Simultaneous Peripheral Operation On Line) or data pumping and pumping. Introduction of pump-pump technology into batch systems The file can be opened for reading or writing, used to retrieve or reset information, and then closed. This is conceptually simpler than worrying about the details of moving disk heads or organizing the operation of a motor. Similarly, with the help of simple and clear abstractions, all unnecessary details of the organization are hidden from the programmer made it possible to combine real input-output operations of one task with the execution of another task, but required the development of a device processor for notification

about the completion of these operations. Magnetic tapes were sequential access devices, meaning information was read from them in the order in which it was written. The advent of a magnetic disk, for which the order in which information is read is not important, that is, a direct access device, led to the further development of computing systems. When processing a batch of jobs on magnetic tape, the order in which jobs were launched was determined by the order in which they were entered. When processing a batch of tasks on a magnetic disk, it became possible to select the next task to be executed. Batch systems

begin to schedule tasks: depending on the availability of the requested resources, the urgency of the calculations, etc. one or another task is selected for the account. processor Further increase in efficiency of use CPU was achieved through multiprogramming. CPU returns to execution of the first program. This idea is reminiscent of the behavior of a teacher and students during an exam. While one student (program) is thinking about the answer to a question (input/output operation), the teacher ( CPU) listens to the answer of another student (calculations). Naturally, this situation requires several students in the room. Likewise, multiprogramming requires having multiple programs in memory at the same time. In this case, each program is loaded into its own section of RAM, called a partition, and should not affect the execution of another program. (Students sit at separate tables and do not prompt each other.)

The emergence of multiprogramming requires a real revolution in the structure of the computing system. Hardware support plays a special role here (many hardware innovations appeared at the previous stage of evolution), the most significant features of which are listed below.

    Implementation of protective mechanisms. Programs should not have independent access to resource allocation, which leads to the emergence of privileged and unprivileged commands. Privileged commands, such as I/O commands, can only be executed operating system. First we will try to answer the question, what is They say it runs in privileged mode. Transfer of control from the application program to First we will try to answer the question, what is accompanied by a controlled regime change. In addition, it is memory protection, allowing competing user programs to be isolated from each other, and

    – from user programs. The file can be opened for reading or writing, used to retrieve or reset information, and then closed. This is conceptually simpler than worrying about the details of moving disk heads or organizing the operation of a motor. Similarly, with the help of simple and clear abstractions, all unnecessary details of the organization are hidden from the programmer Availability . External First we will try to answer the question, what is interrupts . notify that an asynchronous event has occurred, such as an I/O operation completed. Domestic(nowadays they are called First we will try to answer the question, what is exceptional situations

    ) occur when program execution has led to a situation requiring intervention CPU, such as division by zero or an attempt to violate security.

Development of parallelism in architecture. Direct memory access and organization of I/O channels made it possible to free up the central from routine operations. No less important in organizing multiprogramming is the role

    operating system First we will try to answer the question, what is. She is responsible for the following operations. Organization of the interface between the application program and.

    with help processor system calls processor.

    Switching from one job to another requires preserving the contents of the registers and data structures needed to complete the job, in other words, the context to ensure that computation continues correctly.

    Since memory is a limited resource, memory management strategies are needed, that is, it is necessary to streamline the processes of placing, replacing, and retrieving information from memory.

    Organizing the storage of information on external media in the form of files and providing access to a specific file only to certain categories of users.

    Since programs may need to carry out authorized data exchange, it is necessary to provide them with means of communication.

    For correct data exchange, it is necessary to resolve conflict situations that arise when working with various resources and provide for coordination by programs of their actions, i.e.

provide the system with synchronization tools. processor Multiprogramming systems have made it possible to use system resources more efficiently (e.g. , memory, peripheral devices), but they remained for a long time batch

. The user could not directly interact with the task and had to foresee all possible situations using control cards. Debugging programs was still time-consuming and required examining multi-page printouts of the contents of memory and registers or using debug printing. The advent of cathode ray displays and the rethinking of the possibilities of using keyboards brought a solution to this problem. 1) Time-sharing systems, or CPU switches between tasks not only during I/O operations, but also simply after a certain time has passed.

These switches occur so frequently that users can interact with their programs while they are running, that is, interactively. As a result, it becomes possible for several users to work simultaneously on one computer system. Each user must have at least one program in memory for this. To reduce restrictions on the number of working users, the idea of ​​not completely residing the executable program in RAM was introduced. The main part of the program is located on disk, and the fragment that needs to be executed at the moment can be loaded into RAM, and the unnecessary one can be downloaded back to disk. This is implemented using a virtual memory mechanism. The main advantage of such a mechanism is the creation of the illusion of unlimited computer RAM. IN

time sharing systems the user was able to effectively debug the program in interactive mode and write information to disk without using punched cards, but directly from the keyboard. The emergence of on-line files led to the need to develop advanced file systems. In parallel with the internal evolution of computing systems, their external evolution also occurred. Before the beginning of this period, computing systems were, as a rule, incompatible. Everyone had their own Only a part works constantly on the computer operating system , its own command system, etc. As a result, a program that ran successfully on one type of machine had to be completely rewritten and re-debugged to run on another type of computer. At the beginning of the third period, the idea of ​​​​creating families of software-compatible machines operating under the same. The first family of software-compatible computers built on

integrated circuits , became the IBM/360 series of machines. Developed in the early 60s, this family was significantly superior to second-generation machines in terms of price/performance. It was followed by the PDP line of computers, incompatible with the IBM line, and the top model in this line was the PDP-11. the user was able to effectively debug the program in interactive mode and write information to disk without using punched cards, but directly from the keyboard. The emergence of on-line files led to the need to develop advanced file systems.. Millions of lines of Assembly language, written by thousands of programmers, contained many errors, which caused a constant stream of publications about them and attempts to correct them. Only in operating system operating systems OS/360 contained over 1000 known bugs. However, the idea of ​​standardization

was widely introduced into the minds of users and subsequently received active development.

Fourth period (from 1980 to the present). Personal computers. Classic, network and distributed systems The next period in the evolution of computing systems is associated with the emergence of large operating systems integrated circuits

(BIS). These years saw a sharp increase in the degree of integration and a decrease in the cost of microcircuits. A computer that did not differ in architecture from the PDP-11, in terms of price and ease of use, became accessible to an individual, and not to a department of an enterprise or university. The era of personal computers has arrived. Initially, personal computers were intended to be used by one user in a single-program mode, which led to the degradation of the architecture of these computers and their

(in particular, there is no need to protect files and memory, schedule tasks, etc.). Computers began to be used not only by specialists, which required the development of “friendly” software. However, the increasing complexity and diversity of problems solved in

personal computers , the need to improve the reliability of their operation has led to the revival of almost all the features characteristic of the architecture of large computing systems. In the mid-80s, networks of computers, including personal computers, running under the control of network.

These switches occur so frequently that users can interact with their programs while they are running, that is, interactively. As a result, it becomes possible for several users to work simultaneously on one computer system. Each user must have at least one program in memory for this. or distributed operating systems network operating systems users can access the resources of another Only a part works constantly on the computer network computer Only a part works constantly on the computer, only they should know about their presence and be able to do it. Each machine on the network runs under its own local Only a part works constantly on the computer.

, different from stand-alone computer with the presence of additional tools (software support for network interface devices and access to remote resources), but these additions do not change the structure Distributed system has significant differences from autonomous systems.

In the future, autonomous OS we will call them classic operating systems.

Having looked at the stages of development of computing systems, we can identify six main functions that were performed by classical OS in the process of evolution:

    Schedule jobs and usage processor.

    Providing programs with means of communication and synchronization.

    Memory management.

    File system management.

    I/O management.

    Security

Each of the above functions is usually implemented as a subsystem, which is a structural component First we will try to answer the question, what is. In each operating system these functions, of course, were implemented in their own way, to varying degrees. They were not originally designed as components operating systems, but appeared in the process of development, as computing systems became more convenient, efficient and secure. The evolution of computing systems created by man has followed this path, but no one has yet proven that this is the only possible path for their development. OS exist because their existence is currently a reasonable way to use computing systems. Consideration general principles and algorithms for implementing their functions and constitutes the content of most of our course, in which the listed subsystems will be consistently described.

Basic concepts, OS concepts

In the process of evolution, several important concepts arose that became an integral part of theory and practice. First we will try to answer the question, what is. The concepts covered in this section will be encountered and explained throughout the course. A brief description of them is given here.

System calls

At any Millions of lines of Assembly language, written by thousands of programmers, contained many errors, which caused a constant stream of publications about them and attempts to correct them. Only in supports a mechanism that allows user programs to access kernel services First we will try to answer the question, what is. IN operating systems the most famous Soviet computer BESM-6, the corresponding means of “communication” with the kernel were called extracodes, in It would seem that this is an absolutely correct definition, but, as we will see later, in many modern IBM called them system macros, etc. IN First we will try to answer the question, what is Unix such tools are called system calls.

System calls (system calls) is the interface between operating system and user program. They create, delete, and use various objects, the main ones being processes and files. The user program requests a service from from routine operations., carrying out system call. There are libraries of procedures that load machine registers certain parameters and implement interruptprocessor, after which control is transferred to the handler of this call, included in the core Only a part works constantly on the computer. The purpose of such libraries is to make system call similar to normal call subroutines.

The main difference is that when system call The task goes into privileged mode or kernel mode. That's why system calls sometimes also called software interruptions, unlike hardware The file can be opened for reading or writing, used to retrieve or reset information, and then closed. This is conceptually simpler than worrying about the details of moving disk heads or organizing the operation of a motor. Similarly, with the help of simple and clear abstractions, all unnecessary details of the organization are hidden from the programmer which are more often called simply interruptions.

The kernel code runs in this mode from routine operations., and it is executed in the address space and in the context of the task that called it. Only a part works constantly on the computer So the core system call has full access to the user program memory, and when call it is enough to transfer the addresses of one or several memory areas with parameters call.

and the addresses of one or more memory areas for the results In the majority operating systems system call . carried out by the software team interrupt(INT). Software

is a synchronous event that can be repeated when the same program code is executed.

Interrupts Interrupt (hardware interrupt) is an event generated externally (in relation to processor The file can be opened for reading or writing, used to retrieve or reset information, and then closed. This is conceptually simpler than worrying about the details of moving disk heads or organizing the operation of a motor. Similarly, with the help of simple and clear abstractions, all unnecessary details of the organization are hidden from the programmer) device. Through hardware CPU equipment either informs the central The file can be opened for reading or writing, used to retrieve or reset information, and then closed. This is conceptually simpler than worrying about the details of moving disk heads or organizing the operation of a motor. Similarly, with the help of simple and clear abstractions, all unnecessary details of the organization are hidden from the programmer. indicates that an event has occurred that requires an immediate response (for example, the user has pressed a key), or reports the completion of an asynchronous I/O operation (for example, reading data from disk into main memory has finished). Important type of hardware timers, which are generated periodically after a fixed period of time. Interrupts operating system timers are used The file can be opened for reading or writing, used to retrieve or reset information, and then closed. This is conceptually simpler than worrying about the details of moving disk heads or organizing the operation of a motor. Similarly, with the help of simple and clear abstractions, all unnecessary details of the organization are hidden from the programmer when planning processes. . Each type of hardware interrupt has its own number that uniquely identifies the source . Hardware .– this is an asynchronous event, that is, it occurs regardless of what code is being executed

processor

At the moment. Hardware processing should not take into account which process is current. Exceptional situations Exceptional situation (exception) – an event that occurs as a result of a program attempting to execute a command that, for some reason, cannot be completed to completion. Examples of such commands include attempting to access a resource without sufficient privileges or accessing a missing memory page. Exceptional situations Exceptional situations, like system calls, are synchronous events that occur in the context of the current task. can be divided into correctable and incorrigible. in RAM. After eliminating the cause, it is correctable exceptional situation the program can continue to run. Occurrence during work from routine operations. correctable exceptional situations considered normal. Incorrigible exceptional situations . Does all this most often arise as a result of errors in programs (for example, division by zero). Usually in such cases reacts by terminating the program that called it.

exceptional situation

Files are intended for storing information on external media, that is, it is accepted that information recorded, for example, on a disk, should be located inside the file. Typically, a file is understood as a named portion of space on a storage medium. The main purpose of a file system is to hide the features of I/O and give the programmer a simple, abstract model of device-independent files. There is also an extensive category for reading, creating, deleting, writing, opening and closing files system calls Millions of lines of Assembly language, written by thousands of programmers, contained many errors, which caused a constant stream of publications about them and attempts to correct them. Only in(creating, deleting, opening, closing, reading, etc.). Users are familiar with file system organization concepts such as directory, current directory, root directory, and path. To manipulate these objects in (exception) – an event that occurs as a result of a program attempting to execute a command that, for some reason, cannot be completed to completion. Examples of such commands include attempting to access a resource without sufficient privileges or accessing a missing memory page. available First we will try to answer the question, what is. File system

described in lectures 11–12.

Processes, threads First we will try to answer the question, what is Process concept in

one of the most fundamental. The processes are discussed in detail in lectures 2–7. Threads, or lightweight processes, are also described there.

OS architectural features OS So far we have talked about looking at OS from the outside, about what they are doing

. The rest of our course will be devoted to how they do this.

But we have not yet said anything about what they are from the inside, what approaches exist to their construction. The operating system as a protector of users and programs Monolithic core from routine operations. In fact, is a regular program, so it would be logical to organize it in the same way as most programs are organized, that is, composed of procedures and functions. In this case the components are not independent modules, but components of one from routine operations. big program . This structure called monolithic core(monolithic kernel). Monolithic core is a set of procedures, each of which can call each. All procedures run in privileged mode. Thus, Only a part works constantly on the computer monolithic core - this is such a scheme, in which all its components are components of one program, use from routine operations. the core coincides with the entire system.

In many operating systems With . This structure kernel assembly, that is, its compilation, is carried out separately for each computer on which it is installed . Does all this. In this case, you can select a list of hardware and software protocols, support for which will be included in the kernel. Since the kernel is a single program, recompilation is the only way to add new components to it or remove unused ones. It should be noted that the presence of unnecessary components in the kernel is extremely undesirable, since the kernel is always located entirely in RAM. from routine operations. Additionally, eliminating unnecessary components improves reliability

generally. Monolithic core operating systems- the oldest method of organization . This structure. Example of systems with

is most Unix systems. Even in monolithic systems, some structure can be discerned. Just as in a block of concrete one can discern inclusions of crushed stone, so in monolithic core interspersed service procedures corresponding to system calls . Service procedures run in privileged mode, while user programs run in non-privileged mode. To move from one privilege level to another, a main utility program can sometimes be used to determine which one call system call

was done, the correctness of the input data for this

and transferring control to the corresponding service procedure with a transition to the privileged operating mode. Sometimes there is also a set of software utilities that help perform service procedures. Layered systems

Continuing the structuring, it is possible to break the entire computing system into a number of smaller levels with well-defined connections between them, so that objects at level N can only call objects at level N-1. The lowest level in such systems is usually hardware, top level

Layered systems are well implemented. When using lower layer operations, you don't need to know how they are implemented, you just need to understand what they do.

Layered systems are well tested.

Debugging starts from the bottom layer and is carried out layer by layer. When an error occurs, we can be sure that it is in the layer under test. the user was able to effectively debug the program in interactive mode and write information to disk without using punched cards, but directly from the keyboard. The emergence of on-line files led to the need to develop advanced file systems. Layered systems are easily modified. If necessary, you can replace only one layer without touching the others. But layered systems are difficult to develop: it is difficult to correctly determine the order of layers and what belongs to which layer. Layered systems are less efficient than monolithic ones. So, for example, to perform I/O operations, the user program will have to sequentially go through all the layers from top to bottom. The operating system as a protector of users and programs Virtual machines If necessary, you can replace only one layer without touching the others. At the beginning of the lecture we talked about looking at How on virtual machine CPU when the user does not need to know the details of the internal structure of the computer. It works with files, not with magnetic heads and a motor; it works with huge virtual rather than limited real RAM; he doesn’t care much whether he is the only user on the machine or not. Let's consider a slightly different approach. Let . implements . Service procedures run in privileged mode, while user programs run in non-privileged mode. for each user, but not making his life easier, but, on the contrary, complicating it. Only a part works constantly on the computer Each one is like this the user was able to effectively debug the program in interactive mode and write information to disk without using punched cards, but directly from the keyboard. The emergence of on-line files led to the need to develop advanced file systems. virtual machine If necessary, you can replace only one layer without touching the others. appears before the user as bare metal - a copy of all hardware in the computer system, including

, privileged and unprivileged commands, input/output devices, etc. And he is left alone with this iron. When trying to access such virtual hardware at the privileged command level, what actually happens is

real

, which performs all the necessary actions. This approach allows each user to upload their own operating systems on and do with it whatever your heart desires. Rice. 1.3. Virtual machine option The first real system of this kind was the CP/CMS system, or VM/370 as it is now called, for the IBM/370 family of machines. operating systems.

The disadvantage of such

is a decrease in efficiency We will consider the history of the development of computing, and not virtual machines microkernel architecture (microkernel architecture) from routine operations., when most of its components are independent programs. processor In this case, the interaction between them is ensured by a special kernel module called a microkernel. The microkernel operates in privileged mode and ensures interaction between programs and scheduling of use The file can be opened for reading or writing, used to retrieve or reset information, and then closed. This is conceptually simpler than worrying about the details of moving disk heads or organizing the operation of a motor. Similarly, with the help of simple and clear abstractions, all unnecessary details of the organization are hidden from the programmer, primary processing , I/O operations and basic controls

memory. Rice. 1.4.

Microkernel operating system architecture

The remaining components of the system communicate with each other by passing messages through the microkernel. Main advantage microkernel architecture from routine operations.– high degree of core modularity Millions of lines of Assembly language, written by thousands of programmers, contained many errors, which caused a constant stream of publications about them and attempts to correct them. Only in. This makes it much easier to add new components to it. In microkernel you can, without interrupting its operation, load and unload new drivers, file systems, etc. The debugging process is significantly simplified kernel components , because a new version from routine operations. drivers can be loaded without restarting the entire from routine operations.. Kernel components are no fundamentally different from user programs, so you can use ordinary tools to debug them. Microkernel architecture

increases system reliability because a failure at the unprivileged program level is less dangerous than a failure at the kernel mode level. In the same time microkernel operating system architecture The operating system as a protector of users and programs introduces additional overhead associated with message passing, which significantly impacts performance. In order for microkernel was not inferior in speed operating systems on the base monolithic core We will consider the history of the development of computing, and not, you need to very carefully design the division of the system into components, trying to minimize the interaction between them. Thus, the main difficulty in creating microkernels

– the need for very careful design.

Mixed systems operating systems All considered approaches to building OS have their advantages and disadvantages. In most cases modern from routine operations. use various combinations of these approaches. So, for example, the kernel Linux is a monolithic system with elements microkernel architecture

. When compiling the kernel, you can enable dynamic loading and unloading of many kernel components—called modules. When a module is loaded, its code is loaded at the system level and linked to the rest of the kernel. from routine operations. With monolithic core controlled by a microkernel. monolithic core This is how 4.4BSD and MkLinux, based on the Mach microkernel, are designed. The microkernel provides virtual memory management and low-level drivers. Linux is a monolithic system with elements All other functions, including interaction with application programs, are carried out on the base.

. This approach was formed as a result of attempts to take advantage of Linux is a monolithic system with elements, keeping the code as well-debugged as possible on the base Most closely elements operating system and elements operating systems intertwined in the Windows NT kernel. was not inferior in speed With . This structure Although Windows NT is often called microkernel

, this is not entirely true. The NT microkernel is too large (more than 1 MB) to bear the "micro" prefix. The components of the Windows NT kernel are located in preemptible memory and interact with each other by passing messages, as expected in microkernels. operating system.

. At the same time, all kernel components operate in the same address space and actively use common data structures, which is typical

. operating systems According to Microsoft experts, the reason is simple: a purely microkernel design is commercially unprofitable because it is inefficient.

Thus, Windows NT can rightfully be called hybrid

OS classification OS There are several classification schemes

    . Below is a classification based on some characteristics from the user's point of view. Implementation of multitasking

    By the number of simultaneously performed tasks

can be divided into two classes: multitasking First we will try to answer the question, what is".

(Unix, OS/2, Windows); single-tasking (for example, MS-DOS). Multitasking OS First we will try to answer the question, what is.

, solving the problems of resource allocation and competition, fully implements the multi-program mode in accordance with the requirements of the section "Basic concepts, concepts First we will try to answer the question, what is Multitasking mode, which embodies the idea of ​​time sharing, is called preemptive. Each program is allocated a quantum CPU processor First we will try to answer the question, what is time after which control is transferred to another program. They say that the first program will be superseded. Most commercial user programs operate in preemptive mode. processor.

In some First we will try to answer the question, what is MS-DOS can organize the launch of a child task and the presence of two or more tasks in memory at the same time. First we will try to answer the question, what is However, this

traditionally considered to be single-tasking, mainly due to the lack of defense mechanisms and communication capabilities.

Multi-user support First we will try to answer the question, what is By number of concurrent users

    can be divided into:

    single-user (MS-DOS, Windows 3.x); multi-user

(Windows NT, Unix). First we will try to answer the question, what is The most significant difference between these lies in the presence of multi-user systems

mechanisms for protecting the personal data of each user.

Multiprocessing CPU Until recently, computing systems had one central . As a result of demands for increased productivity, multiprocessor systems , memory management, etc. Moreover, on modern computing systems you can create the illusion of unlimited RAM size and number, consisting of two or more First we will try to answer the question, what is general purpose, carrying out parallel execution of commands. Multiprocessing support is an important feature First we will try to answer the question, what is and leads to the complication of all resource management algorithms. Multiprocessing is implemented in such

, like Linux, Solaris, Windows NT, and several others. Multiprocessor OS First we will try to answer the question, what is divided into symmetrical and asymmetrical. In symmetrical on every processor on every the same core functions, and the task can be executed on any , memory management, etc. Moreover, on modern computing systems you can create the illusion of unlimited RAM size and number, that is, processing is completely decentralized. At the same time, each of

all memory is available. In asymmetrical OS processors CPU unequal. There is usually a main CPU.

(master) and subordinates (slave), the workload and nature of which is determined by the master

Real-time systems In rank multitasking OS , along with package systems And time sharing systems , are also included real time systems

, which have not been mentioned so far. They are used to control various technical objects or technological processes. Such systems are characterized by maximum permissible response time to external event

during which the program that controls the object must be executed. The system must process incoming data faster than it can arrive, and from several sources simultaneously. Such strict restrictions affect architecture real time systems

, for example, they may lack virtual memory, the support of which causes unpredictable delays in program execution. (See also the sections related to process scheduling and virtual memory implementation.) First we will try to answer the question, what is is not exhaustive. In more detail, the features of the use of modern First we will try to answer the question, what is reviewed in [ Olifer, 2001].

Conclusion

We looked at different views on what it is The operating system as a protector of users and programs; We will consider the history of the development of computing, and not studied the history of development OS; found out what functions they usually perform operating systems; finally figured out what approaches to building exist

.

We will devote the next lecture to clarifying the concept of “process” and issues of process planning.

Annex 1. CPU Some information about computer architecture The main hardware components of a computer are: main memory, central).

and peripheral devices. To exchange data with each other, these components are connected by a group of wires called a backbone (see Fig. Fig.1.5

Rice. 1.5.

Some computer components . Main memory is used to store programs and data in binary form and is organized as an ordered array of cells, each with a unique digital address. . Typically, the cell size is one byte. Typical operations on main memory are reading and writing the contents of a cell with a specific address.

Various operations with data are carried out by an isolated part of the computer, called the central part. processor(CPU). The CPU also has storage locations called registers. They are divided into general purpose registers and specialized registers. In modern computers, the register capacity is usually 4–8 bytes.

General purpose registers are used to temporarily store data and the results of operations. To process information, data is usually transferred from memory cells to general-purpose registers, and the operation is performed by a central CPU and transferring the results of the operation to the main memory.

The program is executed as follows. The machine instruction pointed to by the program counter is read from memory and copied into the instruction register. Here it is decoded and then executed. After a command is executed, the program counter points to the next command. These actions, called a machine cycle, are then repeated.

Interaction with peripheral devices

Peripheral devices are designed to input and output information. Each device usually includes a specialized computer called a controller or adapter.

When a controller is inserted into a socket on the motherboard, it is connected to the bus and given a unique number (address). The controller then monitors the signals on the bus and responds to signals addressed to it. (hardware interrupt) is an event generated externally (in relation to Any I/O operation involves a dialogue between the CPU and the device controller. When

When an I/O-related command is encountered as part of a program, it executes it by sending signals to the device controller. This is the so-called programmable input/output. CPU In turn, any changes with external devices result in the transmission of a signal from the device to the CPU. From the CPU's point of view, this is an asynchronous event and requires its response. In order to detect such an event, between machine cycles queries a special register containing information about the type of device that generated the signal. If the signal is present, then the CPU performs a specific of this device . a program whose task is to respond to this event appropriately (for example, to enter a character entered from the keyboard into a special buffer). Such a program is called a processing program, and the event itself processor interruption , because it disrupts planned work. After processing is complete The file can be opened for reading or writing, used to retrieve or reset information, and then closed. This is conceptually simpler than worrying about the details of moving disk heads or organizing the operation of a motor. Similarly, with the help of simple and clear abstractions, all unnecessary details of the organization are hidden from the programmer.

processor interrupts

1) returns to program execution.

1. These computer actions are called input/output using

An OS is usually understood as a set of control programs that act as an interface between computer hardware and are designed for the most efficient use of computer system resources and the organization of reliable calculations. Any of the software components runs under the control of the OS, and none of the software components, with the exception of the OS itself, has access directly to the hardware.

The main functions of the OS are:

1. Receiving tasks or commands from the user.

2. Receiving and executing program requests to start, pause and stop other programs.

4. Initiating a program (transferring control to it, as a result of which the processor executes the program).

5. Identification of all programs and data.

6. Ensuring the operation of the file management system and DBMS. which increases the efficiency of the entire software.

7. Providing multiprogramming mode, i.e. execution of 2 or more programs on 1 processor, giving the appearance of their simultaneous execution.

8. Management of input/output operations.

9. Satisfy hard constraints in real time.??

10. Memory distribution, virtual memory organization.

11. Planning and dispatching of tasks in accordance with the specified strategy and service disciplines.

12. Exchange of messages and data between running programs.

13. Protection of programs from influencing each other. ensuring data safety.

14. Providing services in case of system failure.

15. Ensuring the operation of programming systems.

2. Interrupts. Interrupt handling.

Interrupts are a mechanism that allows you to coordinate parallel operation. individual devices computing system and respond to special conditions that arise during processor operation. Interrupts are a forced transfer of control from a running program to the system, and through it to the corresponding interrupt handling program, which occurs when a certain event occurs. The main purpose of introducing interrupts is to implement an asynchronous operating mode and parallelize the operation of individual devices of the computing complex. The interrupt mechanism is implemented in hardware and software.

The structures of interrupt systems can be very different, but they all have common feature– an interruption certainly leads to a change in the order in which instructions are executed by the processor. The interrupt handling mechanism includes the following elements:

1. Establishing the fact of an interruption (reception and identification of an interruption signal).

2. Storing the state of the interrupted process (the state of the process is determined by the value of the program counter, the contents of the processor register, the specification of the mode: user or privileged)

3. Control is transferred by hardware to the interrupt handling program. In this case, the starting address of the interrupt handling subroutine is entered into the program counter, and from the status word into the corresponding registers.???

4. Saving information to an interrupted program that could not be saved using hardware actions.

5. Interrupt handling. The work can be performed by the same subroutine to which control was transferred in the 3rd step, but in the OS this processing is most often implemented by calling the corresponding function. subroutines.

6. restoration of information related to the interrupted process.

7. Return to the interrupted program.

The first 3 steps are implemented in hardware, and the rest in software.

The main functions of the interrupt mechanism:

1. Interrupt recognition or classification.

2. Transfer of control to the interrupt handler.

3. Correct return to the interrupted program

The transition from the interrupted program to the handler and back should be done as quickly as possible. One quick method is to use a soda table. list of all interrupts allowed for a computer and addresses accordingly. handlers. To correctly return to an interrupted program, before transferring control to the handler, the contents of the processor registers are stored either in direct access memory or on the system stack.

Interrupt servicing. The presence of an interrupt signal does not necessarily have to cause an interruption of the executing program; the processor may have an interrupt protection system: disabling the interrupt system or disabling or masking individual interrupt signals. Software control of these facilities allows the OS to regulate the handling of interrupt signals. The processor can process interrupts immediately upon arrival of an interrupt, delay their processing for some time, or completely ignore them. Typically, interrupt operations are performed only after the current command has completed execution. Since interrupt signals occur at random times, at the time of the interrupt there may be several interrupt signals that can only be processed sequentially. To process interrupt signals in a reasonable order, they are assigned priorities. Programs, by managing special mask registers, allow you to implement various service disciplines:

1) with relative priority. In this case, service is not interrupted even if there are requests with higher priorities. after the end of service of this request(current) the request with the highest priority is being served. To organize such a discipline, it is necessary to apply masks to all other interrupts in the program for servicing this request or simply disable the interrupt system.

2) with absolute priority. The tasks with the highest priority are always serviced. To implement this discipline, when requesting interrupt processing, all low-priority interrupts are masked. In this case, a multi-level interrupt is possible, i.e., interrupting the interrupt service program. The number of interrupt levels in this mode varies and depends on the priority of the request based on the stack principle: LCFS - last come first served, i.e. a request with a higher priority can interrupt a request with a lower priority. When an interrupt request appears, the interrupt system identifies the signal and if interrupts are enabled, control is transferred to the appropriate one. interrupt handling program.

Service sections in which the context of the interrupted task is saved and the last section in which the context is restored so that the interrupt system does not respond again to the interrupt request signal. This interrupt system automatically disables interrupts, so it is necessary to re-enable this interrupt system in the interrupt routines. So, while the central interrupt handling section is running, interrupts are enabled, while the final section is running, the interrupt handling subroutine must be disabled, and after the context of the interrupted task is restored, it must be enabled again. These actions must be performed in each interrupt processing. In many OS 1, the interrupt handling section is allocated to a special software module called. interrupt supervisor.

3. What is the difference between reentrant and reinterruptible program modules? How they are implemented.

1. What is a file management system (FMS)?

Purpose of SUF.

Organize more convenient access to data organized as files. Instead of low-level data access - indicating the physical address of each record - logical access is used, indicating the name of the file and the record in it.

A number of operating systems allow you to work with several SUFs; in this case, they talk about mounted file systems. There are also operating systems that work without SUF, i.e. Any file management system is not needed on its own; it is designed to work in a specific OS and a specific file system.

2. External, internal and software interrupts.

Interruptions that occur during computing operation. systems can be divided into external and internal. External interrupts are caused by asynchronous events that occur outside the process being interrupted. Example - timer interrupt, external device interrupt, I/O interrupt, power failure interrupt, operator console interrupt, interrupt from another processor or another OS.

Internal interrupts are caused by events that are related to the operation of the processor and are synchronous with its operations. For example: in case of addressing violation (when a prohibited or non-existent address is specified) or access to a missing segment or page when organizing virtual memory; if there is an unused 2-digit combination in the operation code field; when divided by 0; when order overflows or disappears; when detecting parity errors, errors in the operation of various hardware devices by monitoring means.

Software interrupts. These interrupts occur in response to the corresponding interrupt command, i.e., with this command, the processor performs the same actions as with regular internal interrupts. This mechanism was specifically introduced to ensure that switching to system program modules occurs not just as a transition to a subroutine, but in exactly the same way as in regular interrupts. This ensures that the processor automatically switches to privileged mode with the ability to execute any commands. Signals that cause interruptions are generated outside the processor or in the processor itself, and they can occur simultaneously. The selection of one of them for processing is carried out based on the priority assigned to each type of interrupt. Taking into account interrupt priority can be built into hardware, as well as determined by the OS.