페이지

2022년 4월 29일 금요일

1.10.5 Cloud Computing

 Cloud computing is a type of computing that delivers computing, storage, and even applications as a service across a network. In some ways, it's a logical extension of virtualization, because it uses virtualization as a base for its functionality. For example, the Amazon Elastic Computer Cloud(ec2) facility has thousands of servers, millions of virtual machines, and petabytes of storage available for use by anyone on the Internet. Users pay per month based on how much of those resources they use. There are actually many types of cloud computing, including the following:

- Public cloud- a cloud available via the Internet to anyone willing to pay for the services

- Private cloud- a cloud arun by a company for that company's own use

- Hybrid cloud- a cloud that includes both public and private cloud components

- Software as a service(SaaS)- one or more applications (such as word processors or spreadsheets) available via the Internet

- Platform as a service (PaaS)- a software stack ready for application use via the Internet (for example, a database server)

- Infrastructure as a service(IaaS)- servers of storage available over the Internet (for example, storage available for making backup copies of production data)

These cloud-computing types are not discrete, as a cloud computing environment may provide a combination of several types. For example, an organization may provide both SaaS and IaaS as publicly available services.

Certainly, there are traditional opoerating systems within many of the types of cloud intrastructiore. Beyond those are the VMMs that manage the virtual machines in which the user processes run. At a higher lever, the VMMs themselves are managed by cloud management tools, such as a VMware vCloud Director and the open-source Eucalyptus toolset. These tools manage the resources within a given cloud and provide interfaces to the cloud components, making a good argument for considering them a new type of operating system. 

Figure 1.24 illustraters a public cloud providing IaaS. Notice that both the cloud services and the cloud user interface are protected by a firewall.



1.10.4 Peer-to-Peer Computing

 Another structure for a distributed system is the peer-to-peer(P2P) system model. In this model, clients and servers are not distinguished from one another. Instead, all nodes within the system are considered peers, and each may act as either a client or a server, depending on whether it is requesting or providing a service. Peer-to-peer systems offer an advantage over traditional client-server systems. In a client-server system, the server is a bottleneck; but in a peer-to-peer system, services can be provided by several nodes distributed throughout the network.

To participate in a peer-to-peer system, a node must first join the network of peers. Once a node has joined the network, it can begin providing services to-and requesting service from-other nodes in the network. Determining what services are available is accomplished in one of two general ways:

- When a node joins a network, it registers its service with a centrlized lookup service on the network. Any node desiring a specific service first contacts this centralized lookup service to determine which node provides the service. The remainder of the communication takes place between the client and the service provider.

- An alternative scheme users no centralized lookup service. Instead, a peer acting as a client must discover what node provides a desired service by broadcasting a request for the service to all other nodes in the network. The node (or nodes) providing that service responds to the peer making the request. To support this approach, a discovery protocol must be provided that allows peers to discover services provided by other peers in the network. Figure 1.23 illustrates such a scenario.

Peer-to-peer networks gained widespread popularity in the late 1990s with several file-sharing services, such as Napster and Gnutella, that enabled peers to exchange files with one another. The Napster system used an approach similar to the first type described above: a centralized server maintained an index of all files stored on peer nodes in the Napster entwork, and the actual exchange of files took place between the peer nodes. The Gnutella system used a technique similar to the second tyupe: a client broadcast file requests to other nodes in the system, and nodes that could service the request responded directly to the client. Peer-to-peer networks can be used to exchange copyrighted materials (music, for example) anonymously, and there are laws governing the distribution of copyrighted materal. Notably, Napster ran into legal trouble for copyright infringment, and its services were shut down in 2001. For this reason, the future of exchanging files remains uncertain.

Skpe is another example of peer-to-peer computing. It allows client to make voice calls and video calls and to send text messages over the Internet using a technology known as voice over IP(VoIP). Skype users a hybrid peer-to-peer approach. It includes a centralized login server, but it also incorporates decentralized peers and allows two peers to communicate.


2022년 4월 28일 목요일

1.10.3 Client-Server Computing

 Contemporary network architecture features arrangements in which server systems satisfy requests generrated by client systems. This form of specialized distributed system, called a client-server system, has the general structure depicted in Figure 1.22.

Server system can be broadly categorized as compute servers and file servers:

* The computer-server system provides an interface to which a client can send a request to perform and action (for example, read data). In response, the server executes the action and sends the result to the client. A server running a database that responds to client requests for data is an example of such a system.

* The file-server system provides a file-system interface where clients can create, update, read, and delete files. An example of such a system is a webserver that delivers files to clients running web browsers. The actual contents of the files can vary greatly, ranging from traditional web pages to rich multimedia content such as high-definition video.


1.10.2 Mobile Computing

 Mobile computing refers to computing on handheld smartphones and tablet computers. These devices share the distinguishing physical features of being portable and lightweight. Historically, compared with desktop and laptop computers, mobile systems gave up screen size, memory capacity, and overall functionality in return for handheld mobile access to services such as e-mail and web browsing. Over the past few years, however, features on mobile devices have become so rich that the distinction in functionllity between, say, a comsumer laptop and tablet computer amy be difficult to discern, In fact we might argue that the features of a contemporary mobile device allow it toprovide functionality that is either unavailable or impractical on a desktop or laptop computer.

Today, mobile systems are used not only for e-mail and web browsing but also for playing music and video, reading digital books, taking photos, and recording and editing high-definition video. Accordingly, tremendous growth continues in the wide range of applications that run on such devices. Many developers are now designing applications that take advantage of the unique features of mobile devices, such as global prositioning system (GPS) chips, accelerometers, and gyroscopes. An embedded GPS chip allows a mobile device to use satelites to determine its precise on Earth. That functionality is especially useful in designing applications that provide navigation-for example, telling users which way to walk or drive or perhaps directing them to nearby services, such as restaurants. An accelerometer allows a mobile device to detect its orientation with respect to the ground and to detecct certain other forces, such as titling and shaking. In serveral computer games that employ accelerometers, players interface with the system not by using a mouse or a keyboard but rather by tilting and shaking. In serveral computer games that employ accelerometers, players interface with the system not by using a mouse or a keyboard but rather by tilting and shaking. In several computer games that employ accelerometers, players interface with  the system not by using a mouse or a keyboard but rather by titing, roating, and shaking the mobile device! Perhaps more a practial use of these features is found in augmented-reality applications, which overlay information on a display of the current environment. It it difficult to imagine how equivalent applications could be developed on traditional laptop or desktop computer systems.

To provide access to on-line services, mobile devices typically use either IEEE standard 802.11 wireless or cellular data networks. The memory capacity and processing speed of mobile devices, however, are more limited than those of PCs. Whereas a smarphone or tablet may have 256GB in storage, it isi not uncommon to find 8 TB in storage on a desktop computer, Similarly, because power consumption is such a concern, mobile devices often use processors that are smaller, are slower, and offer fewer processing core than processors found on traditional desktop and laptop computers.

Two operating systems currently dominate mobile computering: Apple iOS and Google Android. iOS was designed to run on Apple iPhone and iPad mobile devices, Android powers smartphones and tablet computers available from many manufacturers. We examine these two mobile operating system in further detail in Chapter 2.


2022년 4월 27일 수요일

1.10.1 Traditional Computing

 As computing has matured, the lines separating many of the traditional computing environments have blurred. Consider the "typical office environment." Just a few yuears ago, this environmnt consisted of PCs connected to a network, with servers profiding file and print services. Remote access was awkward, and porability was achieved by use of laptop computers.

Today, web technologies and increasing WAN bandwidth are stretching the boundaries of traditional c omputing. Companies establish portals, which provide web accessiblity to theiur internal servers. Network computers (or thin clients)-which are essentially terminals that understand web-based computing-are used in place of traditional workstationis where more security or easier maintenance is desired. Mobile computers can synchronize with PCs to allow very portable use of company information. Mobile devices can also connect to wireless networks and cellular data networks to use the company's web portal(as well as the myriad other web resources).

At home, most users once had a single computer with a slow modem connection to the office, the Internet, or both. Today, network-connection speeds once availabe only at great cost azre relatively inexpensive in many places, giving home users more access to more data. These fast data connections are allowing home computers to serve up we pages and to run networks that include printers, client PCs, and servers. Many homes use firewall to protect their networks from security breaches. Firewalls limit the communications between devices on a network.

In the latter half of the 20th century, computing resources were relatively scarce. (Before that, they were nonexistent!) For a period of time, systems were either batch or interactive. Batch systems processed jobs in bulk, with predetermined input from files or other data sources. Interactive systems waited for input from users. To optimize the use of the computing resources, multiple users shared time on these systems. These time-sharing systems used a timer and scheduling algorithms to cycle processes rapidly through the CPU, giving each user a share of the resources.

Traditional time-sharing systems are rare today. The same scheduling technique is still in use on desktop computers, laptaps, servers, and even mobile computers, but frequently all the processes are owned by the same user(or a single user and the operating system). User processes, and system processes that provide service to the user, are managed so that each frequently gets a slice of computer time. Consider the windows created while a user is working at the same time. Even a web broiwser can be composed of multiple processes, one for each website currently being visited, with time sharing applied to each web browser process.

1.10 Computing Environments

 So far, we have briefly described several aspects of computer systems and the operating system that manage them. We turn now to a discussion of how operating systems are used in a variety of computing environments.

2022년 4월 26일 화요일

1.9.4 Bitmaps

 A bitmap is a string of n binary disgits that can be used to represent the status of n items. For example, suppose we have several resources, and the avilability of each resource is indicated by the value of a binary digit:0 means that the resource is availlable, while 1 indicates that it is unavailable )or vice versa). The value of the i(th) position in the bitmap is associated with the i(th) reosurce. As an example,  consider the bitmap shown below:

001011101

Resource 2,4,5,6, and 8 unavailable; resource 0,1,3,and 7 are available.

The power of bitmaps becomes apparent when we consider their space efficiency. If we were to use an eight-bit Boolean value instead of a single bit, the resulting data structure would be eight times larger. Thus, bitmaps are commonly used when there is a need to represent the availability of a large number of resources. Disk direves provide a nice illustration. A medium-sized disk drive might be divided into several thousand individual units, called disk blocks. A bitmap can be used to indicate the availability of each disk block. 

In summary, data strures are prevasive in operating system implementations. Thus, we will see the structures discussed here, along with others, throughout this text as we explore kernel algorithms and their implementation.


1.9.3 Hash Functions and Maps

 A hash function takes data as its input, peforms a numeric operation on the data, and returns a n umberic value. This numeric value can then be used as an index into a table (typically an array) to quickly retrieve the data. Whereas searching for a data item through a list of size n can require up to O(n) compareisons, using a hash function for retrieving data from a table can be as good as O(1), depending on implementation details. Because of this performance, hash function are used extensively in operating systems.

On potential difficulty with hash functions is that two unique inputs can result in the same output value-that is, they can link to the same table location. We can accommodate this hash collision by hav ing a linked list at the table location that contains all of the items with the same hash value. Of course, the more collisions there are, the less efficient the hash functions is.

One use of hash function is to implement a hash map, which associates (or maps)[key:value] pairs using a hash function. Once the mapping is established, we can apply the ahsh function to the key to obtain the value from the hash map(Figure 1.2.1). For example, suppose that a use name is mapped to a password. Password authentication then processds as follows: a user enters which is then used to retrieve the password. The retrieved password is then compared with the password entered by the user for authentication.


2022년 4월 24일 일요일

1.9.2 Trees

 A tree is a data structure that can be used to represent data hierarchically. Data values in a tree structure are linked through parent-child relationships. In a general tree, a parent may have an umlimited number of children. In a binary tree, a parent may have at most two children, which we term the left child and the right child, A binary search tree additionally requires an ordering between the parent's two children in which left_child <= right_child. Figure 1.20 provides an example of a binary search tree. When we search for an item in a binary search tree, the worst0case performance is O(n)(consider how this can occur). To remedy this situations, we can use an algorithm to create a balanced binary search tree. Here, a tree containing n items has at most lg n levels, thus ensuring worst-case performance of O(lg n). We shall see in Section 5.7.1 that Linux uses a balanced binary search tree (known as a red-black tree) as part its CPU-scheduling algorithm.


2. Outline and Perspective

 What we've done so far

- In-depth look at convolution

- CNN architecture

- Use structure of images

- Training + Inference


What we'll do now

- Now that we know the basic pattern, what are some novel architectures that do not follow the basic pattern?(ResNet)

1) We'll also look at VGG and Inception


Transfer Learning

- We've seen that even 3-5 layer nets can take a very long time to train

1) But now we'll be looking at 50 layer nets!

- Researchers today (in machine learning) are committed to openness, and by  sharing their research it is easy for you to do the state-of-the-art at home

Random neural network => TRAINING(ImageNet)=> Neural network <<pre-trained>> on ImageNet =>FINE TUNNG(Your data)=>Trained neural network

1) No other field can archive this:biology, medicine, physics, ... Try building a particle accelerator in your bedroom!

- We can make use of pre-trained weights using transfer learning-significantly reduces training time since we now only need to do fine-tuning

1) Works for completely new/unseen problems, e.g. take inception trained on ImageNet and use it on totally new data


Systems of CNNs

- We tuched on this in Deep Learning pt 8: GANs & Variational Autoencoders

1) System of 2 CNNs -- not real people ->


Object Detection

- SSD

- Both faster and more accurate than previous state-of-the-art

- A prerequisite for any self-driving vehicle



2022년 4월 23일 토요일

1. Introduction

 Advanced Convolutional Neural Networks

- This field has progressed so far!

- I never thought i'd make two CNN courses

- This course is not only way different from CNN pt 1, it is also WAY more massive


Newer, Better Architecures


Object Detection

A CNN is just a part of this system!

Transfer Learning


Random neural network =>(TRAINING:ImageNet)=>Neural network<<pre-trained>> on ImageNet =>FINE TUNING:Your data)=> Trained neural network


SSD

Image(224*224) => Base Network(13*13*512) => Additional Feature Layers

=>

Feature map(Ex1_2 6*6*512) => Feature map (Ex2_2 3*3*256) => Feature map (Ex3_3 2*2*128) => Feature map (GAP 1*1*128) 

=>

Detections Layers => Non-Maximum Suppression => Detection Results





1.9.1 Lists, Stacks, and Queues

 An array is a simple data structure in which each element can be accessed directly. For example, main memory is constructed as an array. If the data item being tstored is larger than one byte, then multiple bytes can be allocated to the item, and the item is addressed as "item number x item size." But what about storing an item whose size may vary? And what about removing an item if the relative positions of the remaining items must be preserved? In such situations, arrays give way to other data structures.

After arrays. list are perhaps the most fundamental data structures in computer science. Whereas each item in an array can be accessed directly, the items in a list must be accessed in a particular order. That is, a list represents a collection of data values as a sequence. The most common method for implementing thsi structure is a linked list, in which items are linked to one another. Linked lists are of several types:

- In a singly linked list, each item points to its successor, as illustrated in Figure 1.17.

- In a doubly linked list, a given item can refer either to its predecessor or to its successor, as illustrated in Figure 1.18.

- In a circularly linked list, the last element in the list refers to the first delement, rather than to null, as illustrated in Figure 1.19.

Linked lists accommodate items of varying sizes and allow easy insertion and deletion of items. One potential disadvantage of using a list is that performance for retrieving a specified item in a list of size n is linear-O(n), as it requires potentially traversing all n elements in the worst case. Lists are some-times used directly by kernel algorithms. Frequently, though, they areused for constructing more powerful data structures, such as stacks and queues.

A stack is a sequentially ordered data structure that uses the last in, first out(LIFO) principle ofr adding and removing items, meaning that last item placed onto a stack is the first item removed. The operations for inserting and removing items from a stack are known as push and pop, respectively. An operating system often uses a stack when invoking function calls. Parameters, local variables, and the reuturn address are pushed onto the stack when a function is called; returing from the function call pops those items off the stack.

A queue, in contrast, is a sequentially ordered data structure that uses the first in, first out(FIFO) principle; items are removced from a queue in the order in which they wwere inserted. There are many everyday exasmples of queues, including shoppers waitting in a checkout line at a store and casrs waiting in line that are sent to a printer are typically printed in the order in which they were submitted, for example. As we shall see in Chapter 5. tasks that are waiting to be run on an available CPU are often organized in queues.



1.9 Kernel Data Structures

 We turn next to a topic central to operating-system implementation: they way data are structured in the system. In this section, we briefly describe several fundamental data structures used extensively in opoerating systems. Readers who require further details on the structures, as well as others, should consult the bibliography at the end of the chapter.

1.8 Distributerd Systems

 A distributed system is collection of physically separate, possibly heterogeneour computer systems that are networked to provide users with access to the various resources that the system maintains. Access to a shared resource increases computation speed, functionallity, data availability, and reliability. Some operating systems generalize network access as a form of file access, with the details of networking contained in the network interface's device driver. 

Others make users specifically invoke networks functions. Generally, systems contain a mix of the two modes-for example FTP and NFS. The protocols that create a distributed system can greatly affect that system's utility and popularity.

A network, in the simplest terms, is a communication path between two or more systems. Distributed systems depend on networking for their functionality. Networks vary by the protocols used, the distances between nodes, and the transport media. TCP/IP is the most common network protocol, and it provides the fundamental architecture of the Internet. Most operating systems support TCP/IP, including all general=-purpose ones, Some systems support proprietary protocols to suit their needs. For an operating system, it is necessary only that a network protocol have an interface device-a network adapter, for example - with a device direver to manage it,  as well as software to handle data. These concepts are discussed throughout this book.

Networks are characterized based on the distances between their nodes. A local-area network(LAN) connects computers within a room, a building, or a compus. A wide-area network(WAN) uaually links buildings, cities, or conuntries. A global company may have a WAN to connect it offices worldwide, for example. These networks may run one protocol or several protocols. The continuing advent of new technologies brings about new forms of networks. For example, a metropolitan-area entwork(MAN) could link buildings within a city. BlueTooth and 80.11 devices use wireless technology to communicate over a distance of serveral feet, in essence creating a personal-area network(PAN) between a phone and a headset or a smartphone and a desktop computer. 

The media to carry networks are equally varied. They include copper wires, fiber strands, and wireless transmissions between satellites, microwave dished, and radios. When computing devices are connected to cellular phones, they create a network. Even very short-range infrared communication can be used for networking. Even very short-range infrared communication can be used for networking. At a rudimentary level, whenever computers communicate, they use or create a network. These networks also vary in their performance and reliability.

Some operating systems have taken the concept of networks and idstributed systems further than notion of providing network connectivity. A network operating system is an operating system that provides features such as file sharing across the network, along with a comunicaste, they use or create a network. These networks also vary in their performance and reliability.

Some operating systems have taken the concept of entworks and distributed systems further than the notion of providing network connnectivity. A network operatins system is an operating system that provides features such as file sharing across the network, along with a communication scheme that allows different processes on different computers to exchange messages. A computer running a network operating system acts autonomously from all able to communicate iwth other networked computer. A distributed operating system provides a less autonomous environment. The different computers communicate closely enough to provide the illusion that only a single operateing system controls the network,. We cover cojmputer nedtworks and distributed system in Chapter 19.

1.7 Virtualization

 Virtualizations is a technology that allows us to abstract the hardware of a single computer (the CPU, memory, disk drivers, network interface cards, and so forth) into several different execution environments, thereby creating the illusion that each separate envirnment is running on its own private computer. These environments can be viewed as different individual operating systems(for example, Windows and UNIX) that may gbe running at the same time and may interact with each other. A user of a virtual machine can switch among the various operating systems in the same way a user can switch among the various operating systems in the same way a user can switch among the various processes runing concurrently in a single operating system.

Virtualization allows operating systems to run as application within other operating systems. At first blush, there seems to be littel reson for such functionality. But the virtualization industry is vast and growing. which is a testament to its utility and importance.

Broadly speaking, virtualization software is one members of a class that also includes emulation. Emulation, which involves simulating computer hardware in software, is typically used when the source CPU type is different from the target CPU type. For example, when Apple switched from the IBM Power CPU to the Intel x86 CPU for its desktop and laptop computers, it included an cmulation facility called "Rosetta," which allowed applications comiled for the IMB CPU to run on th eIntel CPU. That sme concept can be extended to allow an entire operating system written for one platform to run on another. Emulation comes at a heavy price, however. Every machine-level instruction that runs natively on the ousrce system must be translated to the equivalent function on the target system, frequently resulting in serveral target instructions. If the source and target CPUs have similar performance levels, the emulated code may run much more slowly than the native code.

With virtualization, in contrast, an operating system that is natively compiled for a particular CPU architecture runs within another operating system also native to that CPU. Virtualization first came about on IBM mainframes as a method for multiple users to run tasks concurrently. Running multiple virtual machines allowed (and still allows) many users to run tasks on a system designed for a single user. Lather, in response to problems with running multiple Microsoft Windows applications on the Intel x86 CPU, VMware created a new virtualization technology in the form of an application that ran on Windows. That application ran one or more guest copies of Windows or other native x86 operating systems, each running its own applications. (See Figure 1.16)

Windows was the host operating ssytem, and the VMware application was the virtual machine manager(VMM). The VMM runs the guest operating systems, manages their resource use, and protectes each guest from the others.

Even though modern operating systems are fully capable of running multiple applications reliably, the use of virtualization continues to grow. On laptops and desktops, a VMM allows athe user to install multiple operating systems for exploration or to run applications written for operating systems other than the native host. For example, an Apple laptop running macos on the x86 CPUcan run a Windows 10 guest to allow execution of Windows applications. Companies writing software for multiple operating systems can use virtualization to run all of those operating systems on a single physical server for development, testing, and debugging. Within data centers, virtualization has become a common method of executing and managing computing environments. VMMs like VMware ESXand Citrix XenServer no longer run on host operating systems but rather are the host operating systems, providing services and resource management to virtual machine processes.

With this text, we provide a Linux virtual machine that allows you to run Linux-as well as the development tools we provide-on your personnal system regardless of your host operating system. Full details of the features and implementation of virtualization can be found in Chapter 18.

1.6 Security and Protection

 If a computer system has multiple users and allows the concurrent execution of multiple processes, then access to data must be regulated. For that purpose, mechanisms ensure that files, memory segments, CPU, and other resources can be operated on by only those processes that have gained proper authorization from the operating system. For example, memory-addressing hardware ensure that a process can execute only within its own address space. The timer ensures that no process can gain control of the CPU without eventually relinquishing control. Device-control registers are not accessible to suers, so the integrity of the various peripheral devices is protected.

Protection, then, is any mechanism for controlling the access or processes or users to the resources defined by a computer system. This mechanism must provide means to specify the controls to be imposed and to enforce the contorls.

Protection can improve reliablity by detecting latent errors at the interfaces between componet subsystems. Early detection fo interface errors can oftern prevent ocntamination of a healthy subsystem by another subsystem that is malfunctioning. Furthermore, an upprotected resource cannot defend against use(or misuse) by an unauthorized or incompetent suer. A protection-oriented system provides a means to distinguish hetween authorized and unauthorized usage, as we discuss in Chapter 17.

A system can have adequate porotection but still be prone to failure and allow inappropriate access. Consider a user whose authentication information (her means of identifying herself to the system) is stolen. Her data could be copied or deleted, even though file and memory proction are working. It is the job of security to defend a system from external and interanl attacks. Such attacks spread across a huge range and include virusers and worms, denial-of-service attacks (which use all of  a system's resources and so keep legitimate user out of the system). identity theeft, and theft of service (unauthorized use of a system). Prevention of some of these attacks is considered an operating-system function on some systems, whuile other systems leave it to policy or additional software. Due to the alarming rise in security incidenits, operaing-system security features are a fast0growing area of research and implementation. We discuss security in Chapter 16.

Protection and security require the system to be able to distinguish among all its users. Most operating systems maintain a list of user anmes and associated user identifier (user IDs). InWindows parlance, this is a security ID(SID). These numerical IDs are unique,  one per user. When a user logs in to the system, the authentication stage determines the appropriate userID for the user. That user ID is associated with all of the user';s processes and threads. When an ID needs to be readable by a user, it is translated back to the user name via the user name list.

In some circumstances, we wish to distinguish among sets of users rather than individual users. For example, the owner of a file on a UNIX system may be allowed to issue all operations on that file, whereas a selected set of users may be allowed only to read the file. To accomplish this, we need to define a group name and the set of users belonging to that group. Group functionality can be implemented as a system-wide list of group names and group identifier. A user can be in one or more groups, depending on operating-system design decisions. The user's group IDs are also included in every associated process and thread.

In the conurse of normal system sue, the user ID and group ID for a suer are sufficient. However, a user sometimes needs to escalate privilieges to gain extra permissions for an activity. The user may need access to a device that is restricted, for example. Operating systems provide various methods to allow privilege escalation. On UNIZ, for instance, the sctuid attribute on a program causes that program to run with the user ID of the owner of the file, rather than the current user's ID of the owner of the file, rather than the current user' ID. The process runs with this effective UID until it turns off the extra privileges or terminates.


1.5.6 I/O System Management

 One of the purposes of an operating system is to hide the peculiarities of specific hardware devices from the user. For example, in UNIX, the peculiarities of I/O devices are hidden from the bulk of the operating system itself by the I/O subsystem. The I/O subsystem consists of several components:

- A memory-management component that includes buffering, caching, and spooling

- A general device-driver interface

- Drivers for specific hardware devices

Only the device direver knows the peculiarities of the specific device to which it is assigned.

We discussed earlier in this chapter how interrupt handlers and device drivers are used in the construction of efficient I/O subsystems. In Chapter 12, we discuss how the I/O subsystem interfaces to the other system components, manage devices, transfers data, and detects I/O completion.


1.5.5 Cache Management

 Caching is an important principle of computer systems. Here's how it works. Information is normally kept in some storage system (such as main memory). As it is used., it is copied into a faster storage system-the cache-on a temporary basis. When we need a particular piece of information, we first check whether it is in the cache. If it is, we use the information directly from the cache.

If it is not, we use the information from the source, putting a copy in the cache under the assumption that we will need it again soon.

In addition, internal programmable registers provide a high-speed cache for main memory. The programmer (or compiler) implements the registerallocation and register-replacement algorithms to decide which iunformation to keep in registers and which to keep in main memory.

Other caches are implemented totally in hardware. For instance, most system have an instruction cache to hold the instructions expected to be executed next. Without this cache, the CPU would thave to wait serveral cycles while an instruction was tfetched from main memory. For similar resons, most system have one or more high-speed data caches in the memory hierarchy. We are not concerned with these hardware-only cache in this text, since they are outside the control of the operating system.

Because cache have limited size, cache management is an important design problem. Careful selection of the cache size and of a replacement policy can result in greatly increased performance, as you can see by examining Figure 1.14. Replacement algorithms for software-controlled caches are discussed in Caphter 10.

The movement of information between levels of implicit. depending on the hardware design and the controlling operating-system software. For instance, data transfer from cache to CPU and registers is usually a hardware function, with no operating-system intervention. In contrast, transfer of data from disk to memory is usually controlled by the operating system.

In a hierarchical storage structure, the same data may appear in different levels of the storage system. For example, suppose that an integer A that is to be incremented by 1 is located in file B, and file B resides on hard disk. The increment operating proceeds by first issuing an I/O operation is followed by dcopying A to the cache and to an interanl register. Thus, the copy of A appears  internal register (see Figure 1.15). IOnce the increment takes place in the internal register, the value of A differs in the various storage systems. The value of A becomes the sma only after the new value of A is written from the interanl register back to the hard disk.

In a computing environment where only one process executes at a time, this arrangement poses no difficulties, since an access to integer A will always be to the copy at the highest level of the hierarchy. However, in a multitasking environment, where the CPU  is switched back and forth among various processes, extreme care must be taken to ensure that, if several processes wish to access A, then each of these processes will obtain the most recently updated value of A. 

The situation becomes more complicated in amultiprocesssor environment where, in addition to maintaining interal registers, each of the CPUs also contains a local cache (refer back to Figure 1.8). In such an environment, a copy of A may exist simultaneously in several caches. Since the various CPUs can all exeute in parallel, we must make sure that an update to the value of A in one cache is immediately reflected in all other caches where A  resides. This situation is called cache coherency, and it is usually a hardware issue(handled below the operating-system level).

In a distributed environment, the situation becomes even more complex. In this environment, several copies(or replicas)of the same file can be kept on different computers. Since the various replicas may be accessed and updated concurrently, some distributed systems ensure that, when a replica is updated in one place, all other replicas are brought up to date as soon as possible. There are various ways to achieve this gurantee, as we discuss in Chapter 19.


1.5.4 Mass-Storage Management

 As we have already seen, the computer system must provide secondary storage to back up main memory. Most modern computer systems use HDDs and NVM devices as the principal on-line storage media for both programs and data. Most programs-including compilers, web browsers, word processors, and games-are stored on these devices until loaded into memory. The processing. Hence, the proper management of secondary storage is of central importance to a computer system. The operating system is responsible for the following activities in connection with secondary storage management:

- Mounting and unmounting

- Free-space management

- Storage allocation

- Disk scheduling

- Partitioning

- Protection

Because secondary storage is used frequently and extensively, it must be used efficiently. The entire speed of operation of a computer may hinge on the speeds of the seconddary storage subsystem and the algorithms that manipulate that subsystem.

At the same time, there are amny users for storage that is slower and lower in cost (and sometimes higher in capacity) than secondary storage. Backups of disk data, storage of seldom-used data, and long-term archival storage are some examples. Magnetic tape drivers and their tapes and CD DVD and Blu-ray drivers and platters are typical tertiary storage devices.

Tertiary storage is not crucial to system performance, but it still must be managed. Some operating systems take on this task, while others leave tertiary-storage management to application programs. Some of the functions that operating systems can provide include mounting and unmounting media in devices, allocating and freeing the devices for exclusive use by processes, and migrating data from secondary to tertiary storage.

Techniques for secondary storatge and tertiary storage management are discussed in Chapter 11.

2022년 4월 22일 금요일

1.5.3 File-System Management

 To make the computer system convenient for users, the operating system provides a uniform. logical view of information storage. The operating system abstracts from the physical properties of its storage devices to define a logical storage unit, the fil. The operating system maps files onto physical media and accesses these files via the storage devices.

File management it one of the most visible components of an operating system. Computers can store information on several different types of physical media. Secondary storage is the most common, but tertiary storage is also possible. Each of these media has its own characteristics and physical organization. Most are controlled by a device, such as a disk direve, that also has its own unique characteristics. These propertes include access speed, capacity, data-transfer rate, and access method (sequential or random).

A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data. Data files may be numeric, alphabetic, alphanumeric, or binary. File may be freeform(for example, text files), or they may be formatted rigidly (for example, fixed fields such as an mp3 music file). Clearly, the concept of a file is an extremely general one.

The operating system implements the abstract concept of a file by managing mass storage media and the devices that control them. In addition, files are normally organized into directories to make them easier to use. Finally, when multiple users have access to files, it may be desirable to control which user may access a file and how that user amy access if (for example, read, write, append).

The operating system is responsible for the following activities in connection with file management:

- Creating and deleting files

- Creating and deleting directories to organize files

- Supporting primitives for manaipulating files and directories

- mapping files onto mass storage

- Backing up files on stable (nonvolatile) storage media

File-management techniques are discussed in Chapter 13, Chapter 14, and Chapter 15.

1.5.2 Memory Management

 As discussed in Section 1.2.2, the main memory is central to the operation of a modern computer system. Main memory is a large array of bytes, ranging in size from hundreds of thousands to billions. Each byte has its own address. Main memory is a repository of quickly accessible data shared by the CPU and I/O devices. The CPU reads instructions from main memory during the  instruction-fetch cycle (on a von Neumann architecture). As noted earlier, the main memory is generally the only large storage device that the CPU is able to address and access directly. For example, for the CPU to process data from disk, those data must first be transferred to main memory by CPU-generated I/O calls. In the same way, instructions must be in memory for the CPU to execute them.

For a program to be executed, it must be mapped to absolute addresses and loaded into memory. As the program executes, it accesses program instructions and data from memory by generating these absolute addresses. Eventually, the program terminates, its memory space is declared available, and the next program can be loaded and executed.

To improve both the utilization of the CPU and the speed of the computer's in memory, creating a need for memory management. Many different memory management schemes are used. These schemes relect various approaches, and the effectiveness of any given algorithm depends on the situation. In selecting a memory-management scheme for a specific system, we must take into account many factors-especially the hardware design of the system. Each algorithm requires its own hardware support.

The operating system is responsiblie for the following activities in connection with memory management:

- Keeping track of which parts of memory are currently being used and which process is using them

- Allocating and deallocating memory space as needed

- Deciding which processes (or parts of processes) and data to move into and out of memory

Memory-management techniques are discussed in Chapter 9 and Chapter 10.

2022년 4월 19일 화요일

1.5.1 Process Management

 A program can do nothing unless its instructions are executed by a CPU. A program in execution, as mentioned, is a process. A program such as a compiler is a process, and a word-processing program being run by  an individual user on a PC is a process. Similarly, a social media app on a mobile device is a process. For now, you can consider a process to be an instance of a program in execution, but later you will wee that the concept is more general. As described in Chapter 3, it is possible to provide system calls that allow processes to create subprocesses to execute concurrently.

A process needs certain resources-including CPU time, memory, files, and I/O devices-to accomplish its task. These resources are typically allocated to the process while it is running. In addition to the various physical and logical resources that a process obtains when it is created, various initlization data(input) may be passed along. For example, consider a process running a web browser whose function is to display the contents of a web page on a screen. The process will be given the URL, as an input and will execute the appropriate instructions and system calls to obtain and display the desired information on the screen. When the process terminates, the operaing system will reclaim any reusable resources.

We emphasize that a program by itself is not a process. A program is a passive entity, like the contents of a file stored on disk, whereas a process is an active entity. A single-threaded process has one program counter specifying the next instruction to execute.(Threads are coverd in Chapter 4). The execution of such a process must be sequential. The CPU executes one instuction of the process after another, until the process completes. Further, at any time, one instuction at most is executed on behalf of the process. Thus, although two process may be associated with the same program, they are nevertheless considered two separate execution sequences. A multithreaded process has multiple program counters, each pointing to the next instruction to execute for a given thread.

A process is the unit of work in a system. A system consists of a collection of processes, some of which are operating-system processes (those that execute system code) and the rest of which are user processes (those that execute user code). All these processes can potentially execute concurrently-by multiplexing on a single CPU core-or in paralled across multiple CPU cores.

The operaing system is responsible for the following activities in connection with process management:

- Creating an deleting both user and system processes

- Scheduling processes and threads on the CPUs

- Supending and resuming processes

-Providing mechanisms for process synchronization

- Providing mechanisms for process communication

We discuss process-management techniques in Chapter 3 through Chapter 7.


1.5 Resource Management

 As we have seen, an operating system is a resource manager. The system's CPU, memory space, file-storage space, and I/O devices are among the reources that the operating system must manage.

LINUX TIMERS

 On Linux systems, the kernel configuration parameter HZ specifies the frequency of timer interrupts. An HZ value of 250 means that the timer generates 250 interrupts per second, or one interrupt every 4 milliseconds. The value of HZ depends upon how the kernel is configured, as well the machine type and architecture on which it is running. A related kernel variable is jiffies, which represent the number of timer interrupts that have occurred since the system was booted. A programming project in Chapter 2 further explores timing in the Linux kernel.

1.4.3 Timer

 We must ensuire that the operating system maintains control over the CPU. We cannot allow a user program to get stuck in an  infinite loop or to fail to call system services and never return control to the operating system. To accomplish the goal, we can use a timer. A timer can be set to interrupt the computert after a specifed period. The period may be fixed (for example, 1/60 second) or variable (for example, from 1 millisecond to 1 second). A variable timer is generally implemented by a fixed-rate clock and a counter. The operating system sets the counter. Every time the clock ticks, the counter is decremented. When the counter reaches 0, an interrupts at intervals from 1 millisecond to 1,024 millisecond clock allows interrupts at intervals from 1 millisecond to 1,024 milliseconds, in steps of 1 millisecond.

Before turning over control to the user, the operating system ensures that the timer is set to interrupt. If the timer interrupts, control transfers automatically to the operating system, which may treat the interrupt as a fatal error or may give the program more time. Clearly, instructions that modify the content of the timer are privileged.

2022년 4월 18일 월요일

1.4.2 Dual-Mode and Multimode Operation

 Since the operating system and its users share the hardware and sofware resources of the computer system, a properly designed opoerating system must ensure that an incorrect (or malicious) program cannot cause other programs-or the operating system itself-to execute incorrectly. In order to ensure the proper execution of the system, we must be able to distinuish between the execution of operating-system code and user-defined code. The approach taken by most computer systems is to provide hardware support that allows differentiation among various modes of execution.

At the vary least, we need two separate modes of operating; user mode and kernel mode(also called supervisor mode, system mode, or privileged mode). A bit, called the mode bit, is added to the hardware of the computer to indicate the current mode; kernel(0) or user(1). With the mode bit, we can distinguish between a task that is executed on behalf of the operating system and one that is executed on behalf of the user. When the computer system is executing on behalf of a user application, the system is in user mode. However, when a user application requests a service from the operating system(via a system call), the system must transition from user to kernel mode to fulfill the request. This is shown in Figure 1.13. As we shall see, this architectural enhancement is useful for many other aspects of system operation as well.

At system boot time, the hardeare starts in kernel mode. The operating system is then loaded and starts user applications in user mode. Whenever a trap or interrupt occurs, the hardware switches from user mode to kernel mode(that is, changes the state of the mode bit to 0). Thus, whenever the operating system gains control of the computer, it is in kernel mode. The system always switches to user mode(by setting the mode bitg to 1)before passing control to a user program.

The dual mode of operation provides us with the means for protecting the operating system from errant users-and errant users from one another. We accomplish this protection by designating  some of the machine instructions that may cause harm as privileged instructions. The hardware allows privileged instructions to be executed only in kernel mode. If an attempt is made to execute a privileged instruction in user mode. the hardware does not execute the instruction but rather treats it as illegal and traps it to the operating system.

The instruction to switch to kernel mode is an example of a privileged instruction. Some other examples incude I/O control. timer management, and interrupt management. Many additional privileged instructions are discussed throughout the text.

The concept of modes can be extended beyond two modes. For example Intel processors have four separate protection rings, where ring 0 is kernel mode and ring 3 is user mode. (Although rings 1 and 2 could be used for various operating-system services, in practice they are rarely used.) ARMv8 systems have seven modes. CPUs that support virtualization (Section 18.1) frequently have a separate mode to indicate when the virtual machine manager(VMM)is in control of the system. In this mode, the VMM has more privileges than user processes but fewer than the kernel. It needts that level of provilege so it can create and manage virtual machines, changing the CPU state to do so.

We can now better understand the  life cycle of instruction execution in a computer system. Initial control resides in the operating system, where instructions are executed in kernel mode. When control is given to a suer application, the mode is set to user mode. Eventually, control is switched back to the operating system via an interrupt, trap, or a system call. Most contem porary operating systems-such as Microsoft Windows, Unix, and Linux-take advantage of this dual0-mode feature and provide greater protection for the operating system.

System calls provide the means for a user program to ask the operating system to perform tasks rewserved for the operating system on the user program's behalf. A system call is invoked in a variety of ways, depending on the functionality provided by the underlying processor. In all forms, it is the method used by a process to request action by the operating system. A system call usually takes the form of a trap to a specific location in the interrupt vector. This trap can be executed by a generic trap instruction, although some systems have a specific syscall inst5ruction to invoke a system call.

When a system call is executed, it is typically treated by the hardware as a software interrupt. Control passes though the interrupt vector to a service rouine in the operating system, and the mode gbit is set to kernel mode. The system-call service routine is a part of  the operating system. The kernel examines the interrupting instruction to determine what system call has occurred; a parameter indicates what type of service the user program is requesting Additional information needed for the request may be passed in registers, on the stack, or in memory (with pointers to the memory locations passed in registers). The kernel verifies that the parameters are correct and legal, executes the request, and returns control to the instruction following the system call. We describe system calls more fully in Section 2.3.

Once hardware protection is in place, it detects errors that violate modes. These errors are normally handled by the operating system. If a user program fails in some way-such as by making an attempt either to execute an illegal instruction or to access memory that is not in the user's address space-than the hardware traps to the operating system. The trap transfers control through the interrupt vector to the operating system. The trap transfers control through the interrupt vector to the operating system, just as an interrupt does. Wehn a program error occurs, the operating system must terminate the program abnormally. This situaltion is handled by the same code as a user-requested abnormal termination. An appropriate error message is given, and the memory of the program may be dumped. The memroy dump is usually written to a file so that the user or programmer can examine it and perhaps conrrect it and restart the program.



1.4.1 Multiprogramming and Multitasking

 One of the most important aspects of operating systems is the ability to run multiple programs, as a single program cannot, in general, keep either the CPU or the I/O devices busy at all times. Furthemore, users typically want to run more than one program at a time as well. Multiprotramming increases CPU utilization, as well as keeping users satisfied, by oranizing programs so that the CPU always has one to execute. In a multiprogrammed system, a program in execution is termed a process.

The idea is as follows: The operaing system keeps several processes in memory simultaneously (Figure 1.12). The operating system picks and begins to execute one of these processes. Eventually, the process may have to wait for some task, such as an I/O operation, to complete. In a non-multiprogrammed system, the CPU would sit idle. In a multiprogrammed system, the operating system simply switches to, and executes, another process. When that process needs to wait, the CPU switches to another process, and so on. Eventurally, the first process finishes waiting and gets the CPU back, As long as at least one process needs to execute, t he CPU is never idle.

This idea is common in other life situations. A lawyer does not work for only one client at a time, for example. While one case is waiting to go to trial or have papers typed, the lawyer can work on another case. If she has enough clients, the lawyer will never be idle for lack of work. (Idle lawyers tend to become politicians, so there is a certain social value in keeping lawyers busy.)

Multitasking is a logical extension of multiprogramming. In multitasking systems, the CPU execute multiple processes by switching among them, but the switches occur frequently, providing the user with a fast response time. Consider that when a process executes, it typically executes for only a short time before it either finishes or needs to perform I/O. I/O may be interactive; that is, output goes to a sidplay for the user, and input comes from a user keyboard, mouse, or touch screen. Since interactive I/O typically runs at "people speeds," it may taske a long time to complete. Input, for example, may be bounded by the user's typing speed; seven characters per secound is fast for people but incredibly slow for computers. Rather than let the CPU sit idle as this interactive input taskes place, the operating system will repidly switch the CPU to another process.

Having serral processes in memory at the same time requires some form of memory management, which we cover in Chapter 9 and Chapter 10. In addition, if serveral processes are ready to run at the same time, the system must choose which process will run next. Making this desicion is CPU scheduling, which is discussed in Chapter 5. Finally, running multiple processes concurrently requires that their ability to affect one another be limited in all phases of the operating system, including process scheduling, disk storage, and memory management. We discuss these considerations throughout the text.

In a multitasking system, the operating system must ensure reasonable response time. A common method for doing so is virtual memroy, a technique that allows the execution of a process that is not completely in memory(Chapter 10). The main advantage of this scheme is that it enables users to run programs that are larger than actural physical memory. Futher, it abstracts main memory into a large, uniform array of storage, separating logical memory as viewed by the user from physical memory. This arragement frees programmers from concern over memory-storage limitations.

Multiprogramming and multitasking system must also provide a file system(Chapter 13, Chapter 13, and Chapter 15). The file system resides on a secondary storage; hence, storage management must be provided(Chapter 11). In addition, a system must protect resources from inappropriate use (Chapter 17). To ensure orderly execution, the system must also provide mechanisms for process synchronization and communication(Chater 6 and Chapter7), and it may ensure that processes do not get stuck in a deadlock, forever waiting for one another(Chapter 8).


2022년 4월 17일 일요일

1.4 Operating-System Operations

 Now that we have discussed basic information about computer-system organization and architecture, we are ready to talk about operating systems. An operating system provides the environment within which programs are executed. Internally, operating systems vary greatly, since they are organized along many different lines. There are, however, many commonalities, which we consider in this section.

For a computer to start running-for instance, when it is powered up or rebooted-it needs to have an initial program to run. As noted earlier, this initial program, or bootstrap program, tends to be simple. Typically, it is stored within the computer hardware in firmware. It initializes all aspects of the system, from CPU registers to device controllers to memory contents. The bootstrap program must know how to load the operating system and how to start executing that system. To accomplish this goal, the bootstrap program must locate the operating-system kernel and load it into memory.

Once the kernel is loaded an executing, it can start providing services to the system and its users. Some service are provided outside of the kernel by system programs that are loaded into memory at boot time to become system daemons, which run the entire time the kernel is running. In Linux, the first system program is "systemd," and it starts many other daemons. Once this phase is complete, the system if fully booted, and the system waits for some event to occur.

If there are no processes to execute, no I/O devices to service, and no users to whom to respond, an operating system will sit quietly, waiting for something to happen. Events are almost always signaled by the occurrence of an interrupt. In Section 1.2.1 we described hardware interrupts. Another form of interrupt is a trap (or an exception), which is a software-generated interrupt caused either by an error (for example, division by zero or invalid memory access) or by a specific request from a user program that an operating-system service be performed by executing a special operating called a system call.




1.3.3 Clustered Systems

 Another type of multiprocessor system is a clustered system, which gathers together multiple CPUs. Clustered systems differ from the multiprocessor systems described in Section 1.3.2 in that they are composed of two or more individual systems-or nodes-joined together; each node is typically a multicore system. Such systems are considerd loosely coupled. We should note that the definition of clustered is not concrete; many commercial and open source packages wrestle to define what a clustered system is and why one form is better than another. The generally accepted definition is that clustered computers share storage and are closely linked via a local-area network LAN(as described in Chapter 19) or a faster interconnect, such as InfiniBand.

Clustering is usually used to provide high-availability service-that is, service that will continue even if one or more systems in the cluster fail. Generally, we obtain high availability by adding a level of redundancy in the system. A layer of cluster software runs on the cluster nodes. Each node can monitor one or more systems in the cluster fail. Generally, we obtain high availability by adding a level of redundancy in the system. A layer of cluster software runs on the cluster nodes. Each node can monitor one or more of the others (over the network). If the monitored machine fails, the monitoring machine can take ownership of its storage and restart the applications that were running on the failed machine. The users and clients of the applications see only a brief interruption of service. 

High availability provides increased reliability, which is crucial in many applications. The ability to continue providing service proportional to the level of surviving hardware is called graceful degradation. Some systems go beyond graceful degradation and are called fault tolerant, because they can suffer a failure of any to be detected, diagnosed, and, if possible, corrected.

Clustering can be structured asymmetrically or symmetrically. In asymmetric clustering,  one machine is in hot-standby mode while the other is running the applications. The hot-standby host machine does noting but monitor the active server. IOf that server fails, the hot-standby host becomes the active server. In symmetric clustering, two or more hosts are running applications and are monitoring each other. This structure is obviously more efficient, as it uses all of the available hardware. However, it does require that more than one application be available to run.

Since a cluster consists of several computer systems connected via a network, clusters can also be used to provide high-performance computing environments. Such systems can supply significantly greater computational power than single-processor or even SMP systems because they can run an application concurrently on all computers in the cluster. The application must have been written specifically to take advantage of the cluster, however. This involves a technique known as parallelization, which divides a program into separate components that run in parallel on individual cores in a computer or computers in a cluster. Typically, these application are designed so that once each computing node in the cluster has solved its portion of the problem, the results from all the nodes are combined into a final solution.

Other forms of clusters include parallel clusters and clustering over a wide-area network(WAN)(as described in Chapter 19). Parallel clusters allow multiple hosts to access the same data on shared storage. Because most operating systems lack support for simultaneous data access by multiple hosts, parallel clusters usually require the use of special versions of software and special releases of applications. For example, Oracle Real Application Cluster is a version of Oracle's database that has been designed to run on a parallel cluster. Each machine runs Oracle, and a layer of software tracks access to the shared disk. Each machine has full access to all data in the database. To provide this shared access, the system must also supply access control and locking to ensure that no conflicting operations occur. This function, commonly known as a distributed lock manager(DLM), is included in some cluster technology.

Cluster technology is changing rapidly.  Some cluster products support thousands of systems in a cluster, as well as clusted nodes that are separated by miles. Many of these improvements are made posiible by storage-area networks(SANs), as described in Section 11.7.4, which allow many systems to attach to a pool of storage. If the applications and their data are stored on the SAN, then the cluster software can assign the application to run on any host that is attached to the SAN. If the host fails, then any other host can take over. In a databasse cluster, dozens of hosts can share the same database, greatly increasing performance and reliability. Figure 1.11 depicts the general structure of a clustered system.




2022년 4월 16일 토요일

1.3.2 Multiprocessor Systems

 On modern computers, from mobile devices to servers, multiprocessor systems now dominate the landscape of computing. Traditionally, such systems have two (or more) processors, each with a single-core CPU, The processors share the computer bus and sometimes the clock, memory, and peripheral devices. The primary advantage of multiprocessor systems is increased throughput. That is, by increasing the number of processors, we expect to get more work done in less time. The speed-up ratio with N processors is not N, however; it is less than N. When multiple processors cooperate on a task, a certain amount of overhead is incurred in keeping all the parts working correctly. This overhead, plus contention for shared resources, lowers the expected gain from additional processors.

The most common multiprocessor systems use symmetric multiprocessing(SMP), in which each peer CPU processor performs all tasks, including operating-system functions and user processes. Figure 1.8 illustrates a typical SMP architecture with two processors, each with its ovwn CPU. Notice that each CPU processor has its own set of registers, as well as a private - or local - cache. However, all processors share physical memory over the system bus.

The benefit of this model is that many processes can run simultaneously - N processes can run if there are N CPUs - without causing performance to deteriorate significantly. However, since the CPUs are separate, one may be sitting idle while another is overloaded, resulting in inefficiencies. These inefficiencies can be avoided if the processors share certain data structures. A multiprocessor system of this form will allow processes and resources-such as memory- to be shared dynamically among the various processors and can lower the workload variance among the processors. Such a system must be written carefully, as we shall see in Chapter 5 and Chapter 6.

The definition of multiprocessor has evolved over time and now includes multicore systems, in which multiple computing cores reside on a single chip. Multicore systems can be more efficient than multiple chips with single cores because on-chip communication is faster than between-chip communication.

In addition, one chip with multiple core uses significantly less power than multiple single-core chips, an important issue for mobile device as well as laptops.

In Figure 1.9, we show a dual-core design with two cores on the same processor chip. In this design, each core ahs its own register set, as well as its own local cache, often known as a level 1, or L1, cache. Notice, too, that a level2(L2) cache is local to the chip but is shared byu the two processing cores. Most architectures adopt this approach, combining local and shared caches, where local, lower-level caches are generally smaller and faster than higher-level shared caches. Aside from architectureal considerations, such as cache, memory, and bus contention, a multicore processor with N cores apprears to the operating system as N standard CPUs. This characteristic puts pressure on operating-system designers-and application programmers-to make efficient use of these processing cores, an issue we pursue in Chapter 4. Virtually all modern operating systems-including Windows, macOS, and Linux, as well as Android and iOS mobile systems-support multicore SMP systems.

Adding additional CPUs to a multiprocessor system will increase computing power; however, as suggested earlier, the concept does not scale very well, and once we add too many CPUs, contention for the system bus becomes a bottleneck and performance begins to degrade. An alternative approach is instead to provide each CPU (or group of CPUs) with its own local memory that is accessed via a small, fast local bus. The CPUs are connected by a shared system interconnect, so that all CPUs share one physical address space. This approach-known as non-uniform memory access, or NUMA-is illustrated in Figure 1.10. The advantage is that, when a CPU accesses its local memory, not only is it fast, but there is also no contention over the system interconnect. Thus, NUMA systems can scale more effectively as more processors are added.

Apotential drawback with a NUMA system is increased latency when a CPU must access remote memory across the system interconnect, creating a possible performance penalty. In other words, for example, CPU cannot access the local memory of CPU as quickly as it can access its own local memory, slowing down performance. Operating system can minimize the NUMA penalty through careful CPU scheduling and memory management, as discussed in Section 5.5.2 and Section 10.5.4. Because NUMA system can scale to accommodate a large number of processors, they are becoming increasingly popular on servers as well as high-performance computing systems.

Finally, blad servers are systems in which multiple processor boards, I/O boards, and networking boards are placed in the same chassis. The difference between these and traditional multiprocessor systems is that each bladeprocessor board boots independently and runs its own operating system. Some blade-server boasrds are multiprocessor as well, which blurs the lines between types of computers. In essence, these servers consist of multiple independent multiprocessor systems.



1.3.1 Single-Processor Systems

 Many years ago, most computers systems used a single processor containing one CPU with a single processing core. The core is the component the executes instructions and registers for storing data locally. The one main CPU with its core is capable of executing a general-purpose instruction set, including instructions from processes. These systems have other special-purpose processors as well. They may come in the form of device-specific processors, such as disk, keyboard, and graphics controllers.

All of these special-purpose processors run a limited instruction set and do not urn processes, they are managed by the operating system, in that the operating system sends them information about their next task and monitors their status. For example, a disk-controller microprocessor receives a sequence of requests from the main CPU core and implements its own disk queue and scheduling algorithm. This arrangement relieves the main CPU of the overhead of disk scheduling. PCs contain a microprocessor in the keyboard to convert the keystrokes into codes to be sen5t to the CPU. In other systems or circumstances, special-purpose processors are low-level components built into the hardware. The operating system cannot communicate with these processors; they do their jobs autonomously. The use of special-purpose microprocessor. If there is only one general-purpose CPU with a single processing core, then the system is a single-processor system. According the this definition, however, ver few contemporary computer system are single-processor systems.

1.3 Computer-System Architecture

 In Section 1.2, we introduced the general structure of a typical computer system. A computer system can be organized in a number of different ways, which we can categorize toughly according to the number of general-purpose processors used.

1.2.3 I/O Structure

 A large portion of operation system code is dedicated to managing I/O, both because of its importance to the reliability and performance of a system and because of the varying nature of the devices.

Recall from the begining of this section that a general-purpose computer system consists of multiple devices, all of which exchange data via a common bus. The form of interrupt-driven I/O described in Section 1.2.1 is fine for moving small amounts of data but can produce high overhead when used for bulk data movement such as NVS I/O. To solve this problem, direct memory access(DMA) is used. After setting up buffers, pointers, and counters for the I/O device, the device controller transfers an entire block of data directly to or from the device and main memory, with no intervention by the CPU. Only one interrupt is generated per block, to tell the device driver that the operation has completed, rather than the one interrupt per byte generated for low-speed devices. While the device controller is performing these operations, the CPU is available to accomplish other work.

Some high-end systems use switch rather than bus architecture. On these systems, multiple components can talk to other components concurrently, rather than ompeting for cycles on a shared bus, In this case, DMA is even more effective. Figure 1.7 shows the interplay of all components of a computer system.

STORAGE DEFINITIONS AND NOTATION

 The basic u nit of computer storage is the bit. A bit can contain one of two values, 0 and 1. All other storage in a computer is based on collections of bits. Given enough bits, it is amazing how many things a computer can represent: numbers, letters, images, movies, sounds, documents, and programs, to name a few. A byte is 8 bits, and on most computers it is the smallest convenient chunk of storage. For example, most computers don't have an instruction to move a bit but do have one to move a byte.  A less common term is word, which is a given computer architecture's native unit of data. A word is made up of one or more bytes. For example, a computer that has 64-bit registers and 64-bit memory addressing typically has 64-bit (8-byte) words. A computer executes many operations in its native word size rather than a byte at a time.

Computer storage, along with most computer throughput, is generally measured and manipulated in byutes and collections of bytes. A kilobyte, or KB, is 1,024bytes; a megabyte, or MB, is 1,024(2) bytes; a gigabyte, or GB, is 1,024(3) bytes; a terabyte, or TB, is 1,024(4) bytes; a  petabyte, or PB, is 1,024(5) bytes. Computer manufactures often round off these numbers and say that a megabyte is 1 million bytes and a gigabyte is 1 billion bytes. Networking measurements are an exceptioni to this general rule; they are given in bits(Because networks move data a bit at a time).


2022년 4월 15일 금요일

1.2.2 Storage Structure

 The CPU can load instructions only from memory, so any programs must first be loaded into memory to run. General-purpose computers run most of their programs from rewritable memory, called main memory (also called random-access memory, or RAM). Main memory commonly is implemented in a semiconductor technology called dynamic random-access memory(DRAM).

Computers use other forms of memory as well. For example, the first program to run on computer power-on is a bootstrap program, which then loads the operating system. Since RAM is volatile-loses its content when power is turned off or otherwise lost-we cannot trust it to hold the bootstrap program. Instead, for this and some other purposes, the computer uses electrically erasable programmable read-only memory (EEPROM) and other forms of firmwar - storage that is infrequently written to and is nonvolatile. EEPROM can be changed but cannot be changed frequently. In addition, it is low speed, and so it contains mostly static programs and data that aren't frequently used. For example, the iPhone uses EEPROM to store serial numbers and hardware information about the device.

All forms of memory provide an array of bytes. Each byte has its own address. Interaction is achieved through a sequence of load or store instructions to specific memory addresses. The load instruction moves a byte or word from main memory to an internal register within the CPU, whereas the store instruction moves the content of a register to main memory. Aside from explicit load and stores, the CPU automatically loads instructions from main memory for execution from the location stored in the program counter.

A typical instruction-execution cycle, as executed on a system with a von Neumann architecture, first fetches an instruction from memory and stores that instruction in the instruction register. The instruction is then decoded and may cause operands to be fetched from memory and stored in some internal register. After the instruction on the operands has been executed, the result may be stored back in memory. Notice that the memory unit sees only a stream of memory addresses. It does not know how they are generated (by the instruction counter, indexing, indirection, literal addresses, or some other means) or what they are for (instructions or data). Accordingly, we can ignore how a memory address is generated by a program. We are interested only in the sequence of memory addresses generated by the running program.

Ideally, we want the programs and data to reside in main memory permanently. This arrangement usually is not possible on most systems for two reasons:

1. Main memory is usually too small to store all needed programs and data permanently.

2. Main memory, as mentioned, is volatile-it loses its contents when power is turned off or otherwise lost.

Thus, most computer systems provide secondary storage as an extension of main memory. The main requirement for secondary storage is that it be able to hold large quantities of data permanently.

The most common secondary-storage device are hard-disk drivers(HDDs) and nonvolatile memory (NVM) devices, which provide storage for both programs and data. Most programs (system and application) are stored in secoundary storage untile they are loaded into memory. Many programs then use secondary storage as both the loaded into memory. Many programs then use secondary storage as both the source and the destination of their processing. Secondary storage is also much slower then main memory. Hence, the proper management of secondary storage is of central importance to a computer system, as we discuss in Chapter 11.

In a larger sence, however, the storage structure that we have described - consisting of registers, main memory, and secondary storage - is only one of many possible storage system designs. Other possible components include cach memory, CD-ROM or blu-ray, magnetic tapes, and so on. Those that are slow enough and large enough that they are used only for special purposes - to store backup copies of material stored on other devices, for example - are called tertiary storage. Each storage system provides the basic functions of storing a datum and holding that datum until it is retrieved at a later time. The main differences among the various storage system lie in speed, size, and volatility.

The wide variety of storage systems can be organized in a hierarchy(Figure 1.6) according to storage capacity and access time. As a general rule, there is a trade-off between size and speed, with smaller and faster memory closer to the CPU. As shown in the figure, in addition to differing in speed and capacity, the various storage systems are either volatile or nonvolatile. Volatile storage, as mentioned earlier, loses its contents when the power to the device is removed, so data must be written to nunvolatile storage for safekeeping.

The top four levels of memory in the figure are constructed using semiconductor memory, which consists of semiconductor-based electronic circuits. NVM devices, at the fourth level, have several variants but in general are faster than hard disks. The most common form of NVM device is flash memory, which is popular in mobile devices such as smartphones and tablets. Increasingly, flash memory is being used for long-term storage on laptops, desktops, and servers as well.

Since storage plays an important role in operating-system structure, we will refer to it frequently in the text. In general, we will use the following terminology:

- Volatile storage will be referred to simply as memory. If we need to emphasize a particular type of storage device (for example, a register), we will do so explicity.

- Nonvolatile storage retains its contents when power is lost. It will be referred to as NVS. The vast majority of the itme we spend on NVS will be on secondary storage. This type of storage can be classified into two distinct types:

1) Mechanical. A few examples of such storage systems are HDDs, optical disks, holographic storage, and magnetic tape. If we need to emphasize a particular type of mechanical storage device (for example, magnetic tape), we will do so explicitly.

2) Electrical. A few examples of such storage systems are flash memory, FRAM, NRAM, and SSD. Electrical storage will be referred to as NVM. if we need to emphasize a particular type of electrical storage device(for example, SSD), we will do so explicitly.

Mechanical storage is generally larger and less expensive per byte than selectrical storage. Conversely, electrical storage is typically costly, smaller, and faster than mechanical storage.

The design of a complete storage system must balance all the factors just discussed: it must use only as much expensive memory as necessary while providing as much inexpensive, nonvolatile storage as possible. Caches can be installed to improve performance where a large disparity in access time or transfer rate exists between two components.


Intel processor event-vector table

 vector number    :     description

0: divide error

1: debug exception

2: null interrupt

3: breakpoint

4: INTO-detected overflow

5: bound range exception

6: invalid opcode

7: device not available

8: double fault

9: coprocessor segment overrun (reserved)

10: invalid task state segment

11: segment not present

12: stack fault

13: general protection

14: page fault

15: (Intel reserved, do not use)

16: floating-point error

17: alignment check

18: machine check

19-31: (Intel reserved, do not use)

32-255: maskable interrupts

1.2.1.2 Implementation

 The basic interrupt mechanism works as follows. The CPU hardware has a wire called the interrupt-request line that the CPU sense after executing every instruction. When the CPU detects that a controller has asserted a signal on the interrupt-request line, it reads the interrupts number and jumps to the interrupt-handler routline by using that interrupt number as an index into the interrupt vector, It then starts execution at the address associated with that index. Then interrupt handler save any state it will be changing during its operating, determines the cause of the interrupts, performs the necessary processing, performs a state restore, and executes a return from interrupt instruction to return the CPU to the execution state prior to the interrupt. We say that the device controller raises an interrupt by asserting a signal on the interrupt request line, the CPU catches the interrupt and dispatches it to the interrupt, and the handler clears the interrupt by servicing the device. Figure 1.4 summarizes the interrupt-driven I/O cycle.

The basic interrupt mechanism just described enables the SPU to respond to an asynchronous event, as when a device controller becomes ready for service. In a modern operating system, however, we need more sophisticated interrupthandling features.

1. We need the ability to defer interrupt handling during critical processing.

2. We need an efficient way to dispatch to the proper interrupt handler for a device.

3. We need multilevel interrupts, so that the operating system can distinguish between high-and low-priority interrupts and can respond with the appropriate degree of urgency.

In modern computer hardware, these three features are provided by the CPU and the interrupt-controller hardware.

Most CPUs have two interrupt request lines. One is the nonmaskable interrupt, which is reserved for events such as unrecoverable memory errors. The second interrupt line is maskable: it can be turned off by the CPU before the execution of critical instruction sequences that must not be interrupted. The maskable interrupt is used by device controllers to request service.

Recall that the purpose of a vectored interrupt mechanism is to reduce the need for a single interrupt handler to search all possible sources of interrupts to determine which one needs service. In practice, however, computers have more devices (and, hence, interrupt handlers) than they have address elements in the interrupt vector. A common way to solve this problem is to use interrupt chaining, in which each element in the interrupt vector points to the head of a list of interrupt handlers. When an interrupt is raised, the handlers on the corresponding list are called one by one, until one is found that can service the request. This structure is a compromise between the overhead of a huge interrupt table and the inefficiency of dispatching to a single interrupt handler.

Figure 1.5 illustrates the design of the interrupt vector for Intel processors. The events from 0 to 31, which are nonmaskable, are used to signal various error conditions. The events from 32 to 255, which are maskable, are used for purposes such as device-generated interrupts.

The interrupt mechanism also implements a system of interrupt priority levels. These levels enable the CPU to defer the handling of low-priority interrupts without masking all interrupts and makes it possible for a high-priority interrupt to preempt the execution of a low-priority interrupt.

In summary, interrupts are used thoroughout modern operating system to handle asynchronous events(and for other purposes we will discuss throughout the text). Device controllers and hardware faults raise interrupts. To enable the most urgent work to be done first, modern computers use a system of interrupt priorities. Because interrupts are used so heavily for time-sensitive processing. efficient interrupt handling is required for good system performance.


2022년 4월 11일 월요일

1.2.1.1 Overview

 Hardware may trigger an interrupt at any time by sending a signal to the CPU, usually by way of the system bus. (There may be many buses within a computer system, but thesystem bus is the main communications path between the major components.) Interrupts are used for many other purposes as well and are key part of how operating systems and hardware interact.

When the CPU is interrupted, it stops what it is doing and immediately transfers execution to a fized location. The fized location usually contains the starting address where the service routine for the interrupts is located. 

The interrupt service routine executes; on completion, the CPU resumes the interrupted omputation. A timeline of this operation is shown in Figure 1.3.

To run the animation assicated with this figure please click here.

Inerrupts are an important part of a computer architecture. Each computer design has its own interrupt machanism, but serveral funtions are common. The interrupts must transfer control to the appropriate interrupts service routine. The straightforward method for managing this transfer would be to invoke a generic routine to examine the interrupt information. The routine, in turn, would call the interrupt0specific handler. However, interrupts must be handled quickly, as they occur very frequently: A table of pointers to interrupt routine is called indirectly through the table, with no intermediate routine needed.

Generally, the table of pointers is stored in mow memory(the first hundred or so locations). These location hold the addresses of the interrupts service routines of the various devices. This array, or interrupt vector, of addresses is then indexed by a unique number, given with the interrupt request, to provide the address of the interrupt service routine for the interrupting device. Operating system as different as Windows and UNIX dispatch interrupts in this manner.

The interrupt architecture must also svae tghe state information of whatever was  interrupted, so that it can resotre this information after servicing the instance, by modifying register values-it must explicityl save the current state and then resotre that state before retuning. After the interrupt is serviced, the saved return address is loaded into the program counter, and the interrupted computation resumes as though the interrupt had not occurred.


1.2.1 Interrupts

 Consider a typical computer operation performing I/O. To start an I/O operation, the device driver loads the appropriate registers in the device controller, in turn, examines the contents of these registers to determine what action to take (such as "read a character from the keyboard"). The controller starts the transfer of data from the device to its local buffer. Once the transfer of data is complete, the device controller informs the device driver that it has finished its operation. The device driver then gives control to other parts of the operating system, possibly returning the data or a pointer to the data if the operation was a read. For other operations, the device driver returns statrus information such as "write completed successfully" or "device busy". But how does the controller inform the device dirver that it has finished its operation? This is accomplished via an interrupt.

1.2 Computer-System Organization

 A modern general-purpose computer system consists of one or more CPUs and a number of device controllers connected through a common bus that provides access between components and shared memory(Figure 1.2). Each device controller is in charge of a specific type of device (for example, a disk drive, audio device, or graphics display). Depending on the controller, more than one device may be attached. For instance, one system USB port can connect to a USB hub, to which serveral devices can connect, A device controller maintains some local buffer storage and a set of special-purpose registers. The device controller is responsible for moving the data between the peripheral devices that it controls and its local buffer storage.

Typically, operating systems have a device driver for each device controller. This device driver understands the device controller and providers the rest of the operating system with a uniform interface to the device. The CPU and the device controllers can execute in parallel, competing for memory cycles. To ensure orderly access to the shared memory, a memory controller synchronizes access to the memory.

In the following subsections, we describe some basics of how such a system operates, focusing on three key aspects of the system. We start with interrupts, which alert the CPU to events that require attention. We then discuss storage structure and I/O structure.


2022년 4월 10일 일요일

1.1.3 Defining Operating systems

 By now, you can probably see that the term operating system vcovers many roles and functions. That is the case, at least in part, because of the myriad designs and uses of computers. Computers are present within toasters, cars, ships, spacecraft, homes, and businesses. They are the basis for game machines, cable TV tuners, and industrial control systems.

To explain this diversity, we can turn to the history of computers. Although computers have a relatively short history, they have evolved rapidly. Computing started as an experiment to determine what could be done and quickly moved to fixed-purpose systems for military uses, such as code breaking and trajectiory plotting, and governmental users, such as census calculation. Those early computers evolved into general-purpose, multifuctino mainframes, and that's when operating systems were born. In the 1960s, Moore's Law predicted that the number of transistors on an integrated circuit would double every 18 months, and that prediction has held true, Computers gained in functionality and shrank in size, leading to a vast number of users and a vast number and variety of operating systems. (See Appendix A for more details on the history of operating systems.)

How, then, can we define what an operating system is? In general, we have no completely adequate definition of an operating system. Operating systems exist becase they offer a resonable way to solve the problem of creating a usable computing system. The fundamental goal of computer systems is to execute programs and to make solving user problems easier. Computer hardware is constructed toward this goal. Since bare hardware alone is not particularly easy to use, application programs are developed. These programs require certain common operations, such as those controlling the I/O devices. The common functions of controlling and allocating resources are then brought together into one piece of software:the operating system.

In additions, we have no universally accepted definition of what is part of the operationg system. A simple viewpoint is that it includes everything a vendor ships when yuu order "the operating system. "The features included, however, vary greatly across systems. Some systems take up less than a megabyte of space and lack even a full-screen editor, whereas others require gigabytes of spce and lack even a full-screen deitor, whereas others require gigabytes of space and lack even a full-screen ditor , whereas others require gigabytes of space and are based entirely on graphical windowing systems. A more common definition, and the one that we usually follow, is that the operating system is the one program running at all times on the computer - usually called the kernel. Along with the kernel, there are two other types of programs: system programs not associated with the operating of the system.

The matter of what constitutes an operating system become increasingly important as personal computers became more widespread and operating system grew increasingly sophisticated. In 1998, the United States Department of Justice filed suit against Microsoft, in essence claiming that Microsoft included too much functionality in its operating systems and thus prevented application vendors from competing.(For example, a web browser was an integral part of Microsoft's operating systems.) As a result, Microsoft's operating systems.)As a result, Microsoft was found guilty of using its operating-system monopoly to limit competition.

Today, however, if we look at operating systems for mobile devices, we see that once again the number of features constituting the operating system in increasing. Mobile operating systems-Apple's iOS and Google's Android-Features a core kernel along with middleware that supports databases, multimedia, and graphics(to name only a few).

In summary, for our purposes, the operating system includes the always-running kernel, middleware frameworks that ease application development and provide features, and system programs that aid in managing the system while it is running. Most of this text is concerned with the kernel of general purpose operating systems, but other components are discussed as needed to fully explain operating system design and operation.