DHMO


Is it Safe up There?

 

Operating Systems

 

The word “computer” generally conjures up the image of a humming beige box, with a screen full of square windows, a keyboard and a mouse. This type of computer, also known as the “personal computer” or PC is the most prolific form of a device that comes in many sizes, shapes, prices and forms. Over the years computers have been going though tremendous rapid changes in many of its qualities and properties. Today, the computer ranges from huge things as big as 10 refrigerators put together, to smaller than a fingernail. Computer use range from space exploration, telephone switching, personal computing to running a consumer grade microwave oven and ignition control in cars.

 

If we have a calculator and a brick and a computer, which device could be considered the most useful? If you thought of the computer, you may not be correct. The calculator can calculate right out of the box, the brick can be used to build or to maim, but the computer is completely useless, without adding some magic called software.

 

A computer consists of a CPU (central processing unit) some volatile memory (also called main-memory or RAM) and some non-volatile memory (also called disk). When there is nothing in the memories, the computer is as dumb as the brick. The CPU in concept is a simple electronic gadget. It has the capability of doing mathematical functions (add, subtract, and so on) on data stored in main memory. However, unlike the calculator, which can calculate via simple keyboard entries, the computer has to have a program. A program is a series of instructions, also stored in main memory that commands the computer to make tiny steps, one step at a time. Each step is in response to an instruction. Each instruction is a simple command like add or subtract. A current PC does about 1 trillion instructions per second.

 

Given the above, it seems that the computer is just a fast instruction cruncher. How it is useful is not obvious.  Therein comes the software. A piece of software is a set of thousands or millions of instructions that has to be loaded into the memory. Once loaded, the software is able to do all that we are used to—such as word processing, spreadsheets, Email, web browsing, filing and so on. The software that does these useful functions is called “Application Software”, or just “application”. Some applications come bundled with the computer system, some can be purchased readily and some are very specialized and expensive applications used for quite esoteric tasks.

 

In addition to all the application software that we use on our PCs, the PC also contains a huge piece of software, which is larger and more complex than most of the applications we use and this is called the “Operating System”. One of the most dreaded questions that are asked of computer experts is “What is an Operating System?” The news media has a very apt, accurate yet meaningless definition, which states, “An operating system is low-level software, that controls the inner workings of a computer”. The statement looks simple, is absolutely correct yet is quite incomprehensible and useless. Unless of course you know what is “low-level software” and what are those mysterious “inner workings of a computer”.

 

There is no good answer to the question: “What is an operating system?” A fitting analogy is the story about six blind men and an elephant. This story supposedly has its origins in an Indian fable, but was made popular in western world through a poem by John Godfrey Saxe (1816-1887) and starts: “It was six men of Indostan / To learning much inclined, / Who went to see the Elephant / (Though all of them were blind), / That each by observation / Might satisfy his mind.”

 

The six blind men touched the elephant at different parts and came up with wildly different conclusions. The first touched the elephant on its side and decided it is like a wall, the second held the tusk and thought it was like a spear, the third felt the trunk and concluded it is a snake, the fourth hugged the legs and found it like a tree, the fifth found an ear and said it was a fan and the sixth grasped the tail and discovered the elephant is really a rope. Hence, the poem concludes:  “And so these men of Indostan / Disputed loud and long, / Each in his own opinion / Exceeding stiff and strong, / Though each was partly in the right, / And all were in the wrong!”

 

In fact, the operating system is indeed like an elephant. For one thing, it is big, useful but slows things down. For the rest, it is a bewildering mix of functionality, mechanisms, algorithms and control logic that embodies much of the complexity of making a dumb machine pretty useful. Consisting of about 10 million instructions, the current crop of operating systems are incomprehensible (in totality) to even the most qualified experts.

 

If we dissect the operating system, we can find it is a harmonious combination of parts, each part significantly more comprehensible than the whole. The “scheduler” in the operating system manages the proper execution of the programs loaded in memory. A typical home computer at any point in time has about 20 programs loaded, and working together, all using the same single CPU in the computer. The scheduler slices up the CPU into tiny bits of little CPUs in time and hands out each slice of it to each of the programs that want to run simultaneously. Hence the scheduler is constantly running around finding programs to run and then running them and then stopping them and the deciding who goes next. Of course, you may think, why don’t we just do it one at tine, one by one, in a round-robin fashion? Such a simplistic scheduling method leads to poor performance due to a variety of causes too entrenched for a simple explanation.

 

Then there is the Memory Manager. This undercover tyrant is the final authority on who uses how much memory and which part of the memory. It loads the programs when necessary. It knows where they are at all times. It ejects programs from memory when it feels like it. It can even make large programs work even when the computer does not have enough memory to hold them.

 

Adding to the controlled chaos is the device management modules. These handle the disks, the keyboard the mouse and other things connected to the box. The device manger transmits and receives information to and from these peripherals. It controls how and when the little recording heads inside the disk drives move. It detects every keystroke and every mouse movement and advises the window manager of these events. The window manager is the one that makes the pretty screens float around.

 

Every time you move the mouse the little pointer on the screen faithfully mimics your movement. Simple as it may look, it is one of the most complex chains of events that happen inside the computer. As the mouse moves, its little wheel generates a series of electrical pulses. Each pulse is picked up by a device manager, which informs the window manager of this event. On each pulse, the window manager deletes the mouse from where it was (by changing the color of the pixels on the screen to the background color). Then it redraws the mouse pointer at a new location. This is done quickly enough that the mouse seems to move nice and smooth. Yet, tens of thousands of instructions are presented to the CPU, which faithfully executes them, every time we touch the mouse.

 

All this and more (such as networking, file systems and graphics) make up the innards of a modern operating system. Historically, operating systems design and implementation (a fancy word for manufacturing) was the realm of computer vendors. They knew how their computer hardware worked and they designed operating systems for the computers they sold. All that changed, starting with Unix. Unix was designed to run on a variety of different machines and soon became the preferred operating system for computers large and small.

 

In more recent years, the much-maligned Windows (from Microsoft) crept up from behind Unix and took over the desktop. Windows was originally designed for use on small underpowered computers that are used by the pitiable common people. Unix vendors never considered that silly, unsophisticated market to be a threat to their dominance. In reality, the poor man’s computer grew up to become some of the most powerful machines available and computer literacy spread like wildfire. Many of today’s home users rank as high on the literacy scale as the experts of a few years back These budding users got well versed in the Windows world. Even Windows grew up in form and function to become a worthy competitor to Unix. Due to Microsoft’s aggressive positioning and marketing and other smart moves, Windows today, is almost the only game in town.

 

The relationship between the people who prefer Unix (or its variant, called Linux) and those who stoop low enough to touch a product from evil Microsoft is strained (to be polite). Though Windows has won the market share part of the battle, the dominance is definitely not guaranteed forever. Much lies ahead in the war of operating systems and many a white knight is lurking in the shadows.

 

Partha Dasgupta is on the faculty of the Computer Science and Engineering Department at Arizona State University in Tempe. His specializations are in the areas of Operating Systems, Cryptography and Networking. His homepage is at http://cactus.eas.asu.edu/partha

 

 

Partha Dasgupta