3. Publicidad y protección de datos de carácter personal
3.4. Derechos ARCO
figure devices and manage their power consumption. All recent Windows operating systems support and-play; Linux version 2.6 is compatible with many plug-and-play devices.32
Self Review
1. Why, do you suppose, is it necessary for a plug-and-play device to uniquely identify itself.
to the operating system?
2. Why is power management particularly important for mobile devices?
Ans: 1) Before an operating system can configure and make a device available to users, it must determine the resource needs that are unique to the device. 2) Mobile devices rely on battery power; managing a device's power consumption can improve battery life.
2.5 Caching and buffering
In Section 2.3.4, we discussed how computers contain a hierarchy of storage devices that operate at different speeds. To improve performance, most systems perform caching by placing copies of information that processes reference in faster storage.
Due to the high cost of fast storage, caches can contain only a small portion of the information contained in slower storage. As a result, cache entries (also called cache lines) must be managed appropriately to minimize the number of times refer-enced information is not present in cache, an event called a cache miss. When a cache miss occurs, the system must retrieve the referenced information from slower storage. When a referenced item is present in the cache, a cache hit occurs, enabling the system to access data at relatively high speed.33
To realize increased performance from caching, systems must ensure that a signif-icant number of memory references result in cache hits. As we discuss in Section 11.3, Demand Paging, it is difficult to predict with high accuracy the information that pro-cesses will soon reference. Therefore, most caches are managed using heuristics—rules of thumb and other approximations—that yield good results with relatively low execu-tion overhead (see the Operating Systems Thinking Feature, Heuristics).
Examples of caches include the LI and L2 processor caches, which store recently used data to minimize the number of cycles during which the processor is idle. Many operating systems allocate a portion of main memory to cache data from secondary storage such as disks, which typically exhibit latencies several orders of magnitude larger than main memory.
A buffer is storage area that temporarily holds data during transfers between devices or processes that operate at different speeds.34 Buffers improve system per-formance by allowing software and hardware devices to transmit data and requests asynchronously (i.e., independently of one another). Examples of buffers include hard disk buffers, the keyboard buffer and the printer buffer.35, 3fi Because hard disks operate at much slower speeds than main memory, operating systems typically buffer data corresponding to write requests. The buffer holds the data until the hard disk has completed the write operation, enabling the operating system to execute
other processes while waiting for the I/O to complete. A keyboard buffer is often used to hold characters typed by users until a process can acknowledge and respond to the corresponding keyboard interrupts.
Spooling (simultaneous peripheral operations online) is a technique in which an intermediate device, such as a disk, is interposed between a process and a
low-speed or buffer-limited I/O device. For example, if a process attempts to print a doc-ument but the printer is busy printing another docdoc-ument, the process, instead of waiting for the printer to become available, writes its output to disk. When the printer becomes available, the data on disk is printed. Spooling allows processes to request operations from a peripheral device without requiring that the device be ready to service the request.37 The term "spooling" comes from the notion of
wind-ing thread onto a spool from which it can be unwound as needed.
1. How does caching improve system performance?
2. Why do buffers generally not improve performance if one device or process produces data significantly faster than it is consumed?
Ans.: 1) Caches improve performance by placing in fast storage information that a process is likely to reference soon; processes can reference data and instructions from a cache much faster than from main memory. 2) If the producing entity is much faster than the consuming entity. the buffer would quickly fill, then the relationship would be limited by the relatively
Operating Systems Thinking
A heuristic is a "rule of t h u m b " — a strategy that sounds reasonable and when employed, typically yields good results. It often does not have a basis in mathematics because the system to which it applies is sufficiently complex to defy easy mathematical analysis.
As you leave your home each morning, you may use the heuris-tic, "If it looks like rain, take my
umbrella." You do this because from your experience, "looks like
rain" is a reasonable (although
not perfect) indicator that it will rain. By applying this heuristic in the past, you avoided a f e w soak-ings, so you tend to rely on it. As you look at the pile of paperwork on your desk and schedule your work for the day, you may use another heuristic, "Do the short-est tasks first." This one has the satisfying result that you get a bunch of tasks done quickly; on the downside, it has the unfortu-nate side effect of postponing (possibly important) lengthier
tasks. Worse yet, if a steady
stream of new short tasks arrives ) for you to do, you could indefi-nitely postpone important longer tasks. We will see operating sys-tems heuristics in many chapters of the book, especially in the chapters that discuss resource management strategies, such as Chapter 8, Processor Scheduling and Chapter 12, Disk Performance Optimization.
Heuristics
Self Review
80 Hardware and Software Concepts
slow speed of the consuming entity—the producing entity would have to slow down because it would repeatedly find the buffer full and would have to wait (rather than execute at its nor-mally faster speed) until the consumer eventually freed space in the buffer. Similarly, if the consuming entity were faster, it would repeatedly find the buffer empty and would have to slow down to about the speed of the producing entity.
In this section we review basic concepts of computer programming and software.
Programmers write instructions in various programming languages; some are directly understandable by computers, while others require translation. Program-ming languages can be classified generally as either machine, assembly or high-level languages.
A computer can understand only its own machine language. As the "natural lan-guage" of a particular computer, machine language is defined by the computer's hardware design. Machine languages generally consist of streams of numbers (ulti-mately reduced to 1s and Os) that instruct computers how to perform their most ele-mentary operations. Machine languages are machine dependent—a particular machine language can be used on only one type of computer. The following section of an early machine-language program, which adds overtime pay to base pay and stores the result in gross pay, demonstrates the incomprehensibility of machine lan-guage to humans:
1300042774 1400593419 1200274027
As the popularity of computers increased, machine-language programming proved to be slow and error prone. Instead of using the strings of numbers that com-puters could directly understand, programmers began using English-like abbrevia-tions to represent the computer's basic operaabbrevia-tions. These abbreviaabbrevia-tions formed the basis of assembly languages. Translator programs called assemblers convert assembly-language programs to machine-assembly-language. The following section of a simplified assem-bly-language program also adds overtime pay to base pay and stores the result in gross pay, but it presents the steps somewhat more clearly to human readers:
LOAD BASEPAY ADD OVERPAY STORE GR0SSPAY
This assembly-language code is clearer to humans, but computers cannot under-stand it until it is translated into machine language by an assembler program.
2.6.1 Machine language and Assembly language
2.6 Software Overview
Self Review
1. (T/F) Computers typically execute assembly code directly.
2. Is software written in machine language portable?
Ans.: 1) False. Assemblers translate assembly code into machine-language code before the code can execute. 2) No; machine languages are machine dependent, so software written in machine language executes only on machines of the same type.
2.6.2 Interpreters and Compilers
Although programming is faster in assembly languages than in machine language, issembly languages still require many instructions to accomplish even the simplest tasks. To increase programmer efficiency, high-level languages were developed.
High-level languages accomplish more substantial tasks with fewer statements, but require translator programs called compilers to convert high-level language pro-grams into machine language. High-level languages enable programmers to write
instructions that look similar to everyday English and that contain common mathe-matical notations. For example, a payroll application written in a high-level lan-guage might contain a statement such as
grossPay = basePay + overTimePay
This statement produces the same result as the machine-language and assembly-language instructions in the prior sections.
Whereas compilers convert high-level language programs to machine lan-guage programs, interpreters are programs which directly execute source code or code has been reduced to a low-level language that is not machine code. Program-ming languages such as Java compile to a format called bytecode (although Java also can be compiled to machine language), which acts as machine code for a so-called virtual machine. Thus, bytecode is not dependent on the physical machine on which it executes, which promotes application portability. A Java interpreter analyzes each statement and executes the bytecode on the physical machine. Due to the execution-time overhead incurred by translation, programs executed via interpreters tend to execute slower than those that have been compiled to machine code.38, 39
Self Review
1. Discuss the benefits of high-level languages over assembly languages.
2. Why are programs compiled to bytecode more portable than those compiled to machine code?
Ans: 1) High-level language programs require many fewer instructions than assembly-guage programs; also, programming in high-level lanassembly-guages is easier than in assembly lan-guage because high-level lanlan-guages more closely mirror everyday English and common mathematical notations. 2) Bytecode is compiled to execute on a virtual machine that can be installed on many different platforms. By contrast, programs compiled to machine language can execute only on the type of machine for which the program was compiled.