Single Threading and Multithreading Term Paper
- Length: 7 pages
- Subject: Education - Computers
- Type: Term Paper
- Paper: #59510426
Excerpt from Term Paper :
Single and Multithreading
The focus of this report will be to attempt to delve into that void called the operating system and to expose the unique concepts of threading and multithreading. The demand for faster and more powerful computers continues to grow as does the demand for better and faster operating systems. The concept of hyperthreading is the next generation of the idea and will also be touched upon.
Both business and personal computing have become an everyday part of the life for millions of individuals the world over. The majority of individuals who use computers, however, do not actually know what is going on in the background. Operating systems, for example, have always worked on the old notion that one only has to know how to drive the car but not necessarily how the car works. In other words, operating systems do get the work done but the average computer user has no idea what the operating system did to get the work done.
The operating system of a computer is the software that tells the hardware what to do. When a computer user clicks on the mouse button he is really communicating with the operating system as opposed to the mouse. The operating system of a computer is really what makes things happen by determining which tasks or parcels of work will be accomplished and in what order. A very large part of an operating system' tasks are accomplished through the concepts of threading and multithreading. Although the names may sound similar, the ideas of threading and multithreading are wholly quite different but it is better to know how and why they both work.
If someone wants to grasp the concepts of threading and multithreading, it is to the person's advantage to have an understanding of how a computer works and more precisely, how the Central Processing Unit (CPU) works. With that being said, the ideas of threading and multithreading will be clear soon.
In today's computer literate society, Microsoft's Windows program comes to mind in the majority of novices when discussing a computer's operating system. But when discussing the concepts of threading and multithreading, fewer ideas pop into the heads of those novice computer users. Back in July of 1997, when Macintosh was releasing it's latest version of its Apple operating system, OS 8, some hyped Apple users read this in the Washington Times. "More important for users, OS 8 has at its core a multithreaded Finder, which allows you to multitask more easily. You can copy a file - or a disk full of files - in the background while working on other tasks. That is what multithreading allows you to do, and that's what you'll find in OS 8." (Kellner)
To begin the journey into threading, one must have a grasp of what an operating system is and what its functions are. An operating system is technically software that controls the operations of a computer and literally directs the processing of programs by assigning storage space in the memory of the central processing unit and also controlling the input and output functions. The key term here is 'assigning storage space.' Threading and multithreading are concepts that are an important part of how an operating system assigns storage space.
Many people are tricked into thinking that because of the naming convention, the concept of multithreading is a derivative of threading or simply 'threading doubled.' The two concepts are somewhat different and this report will attempt to explain those concepts and differences in easy to follow terms. A brief history of threading, multithreading and the respective backgrounds shall be covered followed with more detail of where and when to use each idea. Next, a general overview of how each of the concepts works will be discussed and then will provide specific details of the ideas with some comparison notes between the two. The report will close out with some detailed performance metrics related to multithreading and insight into the future of the concepts, specifically superthreading and hyperthreading.
Early on in computing, programming was all geared around the single threading concept. Programs were entered or introduced to the CPU through punch cards, tape, or keyboard and the single task operations of the mainframe or early PC's occurred. The concept of time sharing came along as more businesses saw the potential of computing and the idea of sharing the CPU efficiently and fairly became more important. The concept of multiple threads of execution therefore was derived from time sharing systems. Today, as mainframes and desktops become more and more powerful, operating systems were developed to increase the CPU' efficiency by having the operating system literally 'slicing' time up so that programs can run smoothly. Time slicing or, pre-emptive multitasking was created to assist the operating system to be fair for the multiple users on any one system.
Providing insight into how a CPU or microprocessor works is an excellent place to begin when attempting to discuss the concept of a thread. The microprocessor or CPU simply executes a series of machine instructions by telling the processor which instruction came first and storing the other instructions until it is their turn to execute. So, whether a computer is playing music, a game or spell checking a document, simple digital logic techniques allow a computer to do its work. No matter how sophisticated the request is, the microprocessor can only do three basic activities which are:
The CPU can perform mathematical operations: addition, subtraction, multiplication and division.
CPU can move data from one location to another.
CPU can make decisions and jump to a new set of instructions based on those decisions.
With that being said the idea of number two and three above give insight into the concept of threading. A thread is a placeholder for a stored instruction in the microprocessor. I recall reading once that a thread is a programming tool that models concurrency. From a computer program's point-of-view, a thread is the information needed to serve one individual user or a particular service request. If multiple users are using a single program or a request from a different program comes in simultaneously, a thread would therefore be created by the operating system and maintained for each request that came in. The operating system can then easily remember which task came in first and which task needs to go next and so on. So a thread is simply a way for the operating system to keep track of the requests or tasks coming in. The operating system can put in or hold back a thread according to the timing and any demands from other tasks.
The terms task and thread need clarification because they are similar, however, they are not completely synonymous. Most computers can only operate one task at a time but because of the overall speed of the computer, to the user it would seem that multiple tasks are occurring all at once. When a program is started, for example Excel, the operating system gives it a turn. Running Excel is actually many tasks that run in a certain order that makes the spreadsheet for you and I. The operating system runs or executes these tasks in the proper sequence or Microsoft would not be the wealthy conglomerate that it has become. If the user then started MSWord while Excel was running, the series of tasks associated with Word would be properly sequenced and executed, but the operating system would have to take into consideration that two programs with tasks are now running. If the user printed a worksheet, the operating system would have to make the proper input/output (I/O) device available, in this case a printer. The key to remember is that the operating system is limited to one thing at a time. While waiting for the printer to say I am ready, the Operating system assigns the chore of getting the printer a thread. This thread points to all of the relevant data such as which program requested the I/O, what the I/O is and in what order the request came compared to the other tasks and threads in the operating system's memory. When the I/O, or printer for this example, is ready, the operating system can interpret the thread and know to what task the request came and wha 'la, we have a printed spreadsheet. Of course this was overly simplified for the purpose of explanation, but in a nut shell, a thread is how an operating system can tell how to sequence its tasks and other threads.
In a nutshell, multithreading is a technique used by either an operating system or another program that enables the operator to do multiple actions within the same application simultaneously. New operating system technology has been created that would allow programs such as MSWord, which has been written and compiled to run in a certain sequence, to be run out of sequence yet the results still comes out correctly…