Home » Software » Parallel Programming with Multiprocess and Threads

Parallel Programming with Multiprocess and Threads

Linear Versus Parallel Programming

Linear programming involves writing a sequence of program instructions in which each instruction depends on the completion of the previous instruction. Although this is a time-honored and well-worn approach to programming, there are limitations to the linear programming approach when it is used to model the parallel world around us. You would be very limited if you were able to accomplish only one task at a time and you had to complete that task before you could start a new task. For example, suppose you sat down to read your mail and the phone rang. In a linear world you wouldn’t be able to answer the phone until you finished reading your mail. Now suppose that while you were reading your mail and the phone was ringing, your neighbors dropped by and rang the doorbell to say hello. You wouldn’t be able to open the door until you had completed your phone call, but you couldn’t complete your phone call until you finished reading your mail. You can see how your daily tasks would pile up one behind another very quickly in a linear world. In a parallel world you can use the concept of multitasking to accomplish all these tasks at the same time. There are three types of processing. They are

  1. Linear Processing
  2. Pseudo-parallel processing
  3. Parallel processing

Types-of-Processing Parallel Programming with Multiprocess and Threads

Multitasking as Time-Sharing

Multitasking was originally developed as a way for many users to share a single central processing unit (CPU) on a large, centralized computer system such as a mainframe. It was accomplished by allocating to each system user a portion of the available CPU time, a technique generally referred to as time-sharing . In theory, if there were not too many users and the CPU was sufficiently fast, each user would be unaware of the presence of the others. In practice, time-sharing rarely worked that well.

In the world of computing today the mainframe time-sharing environments have for the most part been replaced by distributed computing environments that consist of a network of PCs, one PC (and its CPU) for each user, eliminating the need for users to share a CPU. As a result, multitasking has evolved as a way for a single user to run many programs at the same time on a single CPU while still allowing the user to maintain control over the CPU.

Preemptive Multitasking

CPU was left up to the programs themselves, with each program voluntarily giving up control of the CPU to allow other programs access to the CPU. Unfortunately, as on any school playground, not every program was written to “play fair,” and it took only one program “bully” to tie up the CPU, leaving the user helpless to regain control of the PC. PCs have since evolved to include hardware that is capable of interrupting the program that is running and instructing the CPU to run another program, i.e., the operating system, to ensure that the CPU is shared equally among the other programs. This is known as preemptive multitasking because a running program can be preempted at any time by the hardware interrupt system, allowing access to the CPU in a way that is predictable, independent of the programs that are running, and adjustable, based on criteria such as priority.

Multithreading-improves-pipeline-efficiency Parallel Programming with Multiprocess and Threads

One thought on “Parallel Programming with Multiprocess and Threads

  1. Timberland says:

    Hey There. I found your blog using msn. This is an extremely well written article. I will make sure to bookmark it and come back to read more of your useful info. Thanks for the post. I will definitely comeback.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website