A sequential program has a single thread of control. Its execution is called a process. A concurrent program has multiple threads of control. They may be executed as parallel processes. This lesson presents main principles of concurrent programming. A concurrent program can be executed by
Concurrent programs are governed by two key principles. These are the principles of "safety" and "liveness".
If we read/modify/write a file and allow operations to interrupt one another, the file might be easily corrupted. Safety is ensured by implementing
The problems of deadlock and starvation bring us to the next big topic in concurrent programming − liveness. Concurrent programs are also described as having a ‘liveness’ property if there are:
Co-routines are only pseudo-concurrent and require explicit transfers of control:
Co-routines can be used to implement most higher-level concurrent mechanisms. Fork can be used to create any number of processes:
Join waits for another process to terminate. Fork and join are unstructured, so require care and discipline. Cobegin/coend blocks are better structured, but they can only create a fixed number of processes.
The caller continues when all of the co-blocks have terminated.
10 videos|99 docs|33 tests
|
1. What is concurrency in computer science engineering? |
2. How is concurrency achieved in computer science engineering? |
3. What are the benefits of concurrency in computer science engineering? |
4. What are the challenges or issues associated with concurrency in computer science engineering? |
5. How can concurrency be implemented safely in computer science engineering? |
|
Explore Courses for Computer Science Engineering (CSE) exam
|