Uploaded by kimsunggyuzizi89

How the Operating System and Hardware Work Together

advertisement
How the Operating System and
Hardware Work Together
• A computer’s OS provides a number of critical services, including a
user interface, memory management, a file system, multitasking, and
the interface to hardware devices.
• Without an OS, each application would have to provide these
services, and if a user wanted to run multiple applications at once
(multitasking), the applications would have to run cooperatively.
User Interface
• The user interface enables people to interact with computers.
• With graphical user interfaces (GUIs), users can point and click their
way around the computer to run applications, access network
services, manage hard drives and files, and configure the working
environment to their liking.
• In short, users provide input, and the OS, along with the CPU,
processes that input, whether it’s mouse clicks or keystrokes, and
generates output.
• Without a user interface, computers could process only information
that has been programmed into memory or storage.
• If something went wrong, there would be no way to indicate the
problem to a person, making a computer without a user interface of
little value except when it has a narrowly defined task, such as
running a piece of machinery.
Memory Management
• Computers are now equipped with memory measured in hundreds of
megabytes or gigabytes, whereas in the early 1990s, the typical amount of
memory was about 1 megabyte.
• Each application requires a certain amount of memory in which to run.
• When the OS loads an application, memory must be allocated for the
application to run in, and when the application exits, the memory it was
using must be marked as available.
• The OS handles these memory management tasks.
• Without a central memory manager, an application could use any memory
in the system, and it might be memory already being used by a running
application or the OS itself.
• If this happens, the system can crash or perform erratically. Today’s
OSs usually detect an application’s attempt to access another
process’s memory and force the offending application to terminate.
File System
• The file system is used to organize space on storage devices, such as
disk drives and flash drives, for the purpose of storing and locating
files.
• Contemporary file systems typically have the following objectives:
• Provide a convenient interface for users and applications to open and save
files.
• Provide an efficient method to organize space on a drive.
• Provide a hierarchical filing method to store files.
• Provide an indexing system for fast retrieval of files.
• Provide secure access to files by authorized users.
• When a user double-clicks a file to open it, the user interface calls the
file system with a request to open the file.
• The file type determines exactly how the file is opened.
• If the file is an application, the application is loaded into memory and
run by the CPU.
• If the file is a document, the application associated with the
document type is loaded into memory and opened by the application.
• For example, if you double-click the Budget.xls file, the Excel
application is loaded into memory and then opens the Budget.xls
document file.
• If a user creates a new file or changes an existing file and wants to
save it, the application calls the file system to store the new or
changed file on the disk.
• Most users of an OS interact with the file system by using Windows
Explorer or a similar file manager program on another OS, but as a
future computer or network professional, you need to have a deeper
understanding of how a file system works so that you can make
informed choices when you need to install a file system or
troubleshoot file system-related problems.
Multitasking
• Quite simply, multitasking is an operating system’s capability to run
more than one application or process at a time.
• Multitasking is what allows you to listen to a music file while browsing
the Web, for example.
• Computer hardware can’t do that by itself.
• The OS is designed to look for applications that have some kind of
work to do (such as load a new Web page or continue playing the
current music file) and then schedule CPU time so that the work gets
done.
• For example, if you’re browsing the Web and reading the current page
loaded in your Web browser, the computer isn’t really doing any
work.
• However, if you click a link on the Web page, you’re telling the Web
browser you want to load a new page.
• The OS responds by telling the CPU to start executing the part of the
Web browser application responsible for loading a new Web page.
• You might wonder how can you play a music file at the same time the
CPU is loading a new Web page.
• There are two possible answers:
• The computer contains more than one CPU or a
• multicore CPU and can literally do two things at once (in this case, load a Web
page and play a music file), or the OS instructs the CPU to switch between the
two tasks rapidly, giving the illusion that they’re happening simultaneously.
• Because CPUs can execute hundreds of millions of instructions per
second, this illusion isn’t difficult to carry off.
Interface to Hardware Devices
• When an application needs to communicate with computer
hardware, as when writing information to the display device or
sending data to the network, it calls on the OS, which then calls on a
device driver.
• A device driver is software that provides the interface between the
OS and computer hardware.
• The reason the application can’t simply read or write data directly to
hardware is that other applications might also need to communicate
with the same device at the same time.
• If this were allowed to happen, it would be akin to two or more
people on different extensions of the same land line trying to dial a
different number.
• Nobody’s phone call would go through, or one person might call an
unintended destination.
• The OS queues up each request and sends it to the device driver
when it’s not busy.
• This procedure ensures that every application’s request is taken care
of in a nice orderly fashion.
• Every device performing an input or output function requires a device
driver.
• When an input device has data ready for processing, or when an
output device is ready to accept data, the device must signal the OS.
• Most devices use a signal called an interrupt to let the OS know it has
data ready to be read or is ready for more data to be written.
• Computers spend a considerable amount of time servicing interrupts
on a busy computer.
• For example, when the mouse is moved or a key on the keyboard is
pressed, an interrupt is generated so that the OS knows the mouse
pointer must be redrawn onscreen or a character must be written to
the screen.
• On a networked computer, an interrupt is generated by the NIC when
a packet arrives.
• Every time an interrupt occurs, the OS must stop what it’s doing to
service the interrupt.
• It takes many instructions for an OS to stop what it’s doing, service
the interrupt, and then resume what it was doing before the interrupt
occurred.
• Because computers can execute millions of instructions per second,
users don’t usually notice the interruption.
• If enough interrupts occur simultaneously and for a prolonged period,
however, a system can become noticeably sluggish or even seem to
freeze.
• Malfunctioning hardware and network errors that generate excessive
packets are two of the many possible causes of this problem.
• Remember this idea about excessive interrupts caused by the NIC.
Download