Code Monkey home page Code Monkey logo

java-mod-5-program-execution-types's Introduction

Program Execution Types

Learning Goals

  • Explain the different types of program execution types.
  • Explain the difference between concurrent and parallel programs.

Introduction

Program Instructions are executed by the CPU. Instructions can be run in different orders. If a program performs multiple tasks, sometimes it can be programmed to run these tasks at the same time instead of completing them one by one. This comes with various tradeoffs that we’ll discuss in later lessons.

Synchronous Execution

If programs are run completely synchronously by a system, each task is scheduled one at a time on the CPU. Every single task must be run to completion before any other task can be scheduled.

Concurrent Execution

A program is concurrent if it can be broken down into multiple tasks which can be executed out of order or in partial order without changing the result. Concurrent systems can either run multiple distinct programs or multiple tasks of the same program in overlapping time intervals.

Although concurrent programs can have multiple tasks in progress at the same time, the CPU doesn’t execute instructions of the various tasks at the same time. Their execution is interleaved which means each task is given some time on the CPU before being switched out for another task.

As an example, a web browser that runs on a system with a single core is concurrent. The browser has to be able to process user input while still rendering content on screen. If the user performs an action while content is being loaded, the loading process will be paused to acknowledge and process the user’s input.

Parallel Execution

Parallel execution allows a system to run multiple programs or tasks at the same time unlike in concurrent execution where one task has to be suspended in order to process another. Note that a program does have to be concurrent, i.e., parts of the program has to be able to run independently without changing the final result in order to run the program in parallel.

Almost all modern computers and mobile devices have CPUs with multiple cores which means each core can process different programs or tasks at the same time. Chances are that there are multiple programs running on the device you’re currently reading this on!

Conclusion

We’ve learned that concurrency is a method of handling multiple programs or tasks by scheduling them in a certain way and parallelism is a way to run multiple tasks simultaneously.

java-mod-5-program-execution-types's People

Contributors

alveem avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.