Program execution model


















In a multi-threaded programming language such as Java, C , Go, Scala, among many others , the master thread main program logic will start a second thread to handle the first request, and another for the second one. Each thread runs in parallel with the rest.

Once each thread completes running each can end at different times , they will re-synchronize with the main thread and combine results and get the final one. Since most modern computers contain multiple CPU cores and some, even multiple CPUs with multiple cores , multiple threads can run at the same time, one using a different core, avoiding blocking the CPU while waiting for results.

Going back to the office worker example, a multi-threaded execution model would send several emails one for each request in parallel and waiting for all of them to return before completing the work. This execution model has the advantage of optimizing CPU resources by running several threads in parallel making use of different CPU cores , reducing the time it takes to complete a program.

However, managing several many, in some cases threads and synchronizing them with the master thread can make the code quite complex and difficult to debug. This also makes the learning curve quite steep to newcomers.

All these kind of operations are done in parallel to the execution of your code. However, in this model, only one thread of execution is used. No additional threads are created. Unlike the previous models, in the asynchronous execution model the main program flow continues to run right after the call is made before getting the results , as in a multi-threaded model but without spawning extra threads of control.

When the action completes e. To put it another way, the main program flow continues its normal execution of code until a new result arrives from a previous function call and its callback function needs to run. This makes the program more efficient, as the CPU is always running, either on the main program or a callback.

JavaScript programming platforms—browsers and Node. NodeJS implements this execution model, via its Event Loop , which takes care of managing the program flow and callback invocations. The models described above are not the only ones. However, the ones above cover most of the programming languages used these days. This provides better performance by optimizing CPU usage.

In addition, this model is affected by some system-specific constraints, such as the maximum number of threads which may also play against using this model. It simply take the php file as it's input, parse and interpret it and then return what ever output the script produced, pass it back to apache as response that will return back to requesting user browser.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more.

What is an execution model in programming languages? Ask Question. Asked 3 years, 11 months ago. Active 1 year, 6 months ago. Viewed 1k times. I've been reading Wikipedia article about execution model which said that: An execution model specifies how work takes place.

Improve this question. The Wiki article seems to be making a very wild claim. I don't find anything resembling a specific 'execution model' in for example the COBOL specifications. Add a comment. Active Oldest Votes. Improve this answer. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.



0コメント

  • 1000 / 1000