Click the button to start reading
7 Advantages of Cooperative Multitasking (And 4 Disadvantages)
Cooperative multitasking is a technique where two or more software applications will share the same resources of a common host processor. This method will queue tasks and attempt to allocate resources between them periodically.
Only one task can run at a time and the program must yield control before the next task can run. This type of multitasking is most useful when concerning a single user with just a handful of tasks.
This method is less popular with modern computers but was heavily used during the 16-bit era. Nowadays cooperative multitasking is used mainly where memory constraints exist.
It’s common to see cooperative multitasking in applications like CICS (Customer Information Control System) or the JES2 (Job Entry System) subsystem.
The operating system will never perform a context switch between processes. If running multiple programs, processes will yield control voluntarily when the process goes idle or is logically blocked by another program. Alternatively, they will cede control periodically so both programs can function.
Now let’s take a look at the main advantages of cooperative multitasking.
1. CPU Isn’t Being Overworked
Since cooperative multitasking focuses on a single process at a time, the full resources of the CPU can be focussed on the task. When multiple programs are being run simultaneously it can slow down progress and it greatly reduces the processing power each program has access to.
With the CPU able to focus its processing power on individual tasks it can complete tasks faster and more effectively. Other types of multitasking lack this individuality and the processing power is split between tasks.
2. Exchanging Data Is A Breeze
Predictable processes are a big benefit to cooperative multitasking. They allow for simpler profiling and testing regardless of when incidents occur. Different people can see the same view as one another even if they are not accessing the project at the same point.
3. Easy to Implement
As with anything, how effective your cooperative multitasking is, is down to the skills of the coder. However, cooperative multitasking is simpler to code than other types of multitasking. There will be no need to implement suspending code as each process will be responsible for yielding control,
This makes cooperative multitasking ideal for single users with a small number of tasks to do. As an individual coder, this should make the coding process nice and easy.
4. Available in Popular Programming Languages
Cooperative multitasking is predominantly used with popular languages such as Python and Javascript. These programs feature single-threaded event-loops during their runtime which is utilized by cooperative multitasking. Anyone familiar with these languages will find coding a cooperative multitasking system quite easy.
5. Fewer Re-Entrance Issues
Providing there is only a single CPU kernel, you can expect there to be fewer issues with re-entrance. However, this benefit won’t be available if you use multiprocessor kernels.
As there is no chance of tasks or programs being interrupted by other tasks there shouldn’t be re-entrance issues. Interruptions that happen during cooperative multitasking are typically kernel calls, which the coder will permit.
6. Know How Long Processes Will Stay Awake
Another benefit of cooperative multitasking is knowing the exact time frame processes will take. This may need some additional coding but it’s nothing too strenuous. All the coder will need to do is set up loops and events for threads.
Doing this will help you monitor if tasks are taking too long and hindering progress. You’ll also be able to make sure that all your tasks are getting access to the CPU without the hassle of trying to access resources.
7. Great for Single Users
Cooperative multitasking is great when it’s for a single user who only has a few tasks to complete. It will be lackluster if there are many tasks or multiple users trying to run different processes.
Although the principles of cooperative multitasking sound good, modern technology is too powerful. This means that you’ll be better off with preemptive multitasking. However, it can still be useful on embedded devices.
Disadvantages of Cooperative Multitasking
Now we’ve gone over what cooperative multitasking is and the advantages it holds, we should look at the disadvantages. Unfortunately, cooperative multitasking is used less and less in modern technology.
It was used frequently during the 16-bit era by both Microsoft and Apple. This was due to the code being easy to write and being able to run on less advanced (and less costly) hardware. Here are some of the major disadvantages of cooperative multitasking.
1. Poor coding can cause issues
If one of the programs or tasks isn’t coded correctly it can cause major issues. One such issue is that a program could hold the CPU forever instead of yielding control. This will mean that other tasks won’t be completed and the only way to release the CPU is by shutting down the computer.
It can be a particular problem in a server environment as it can cause the entire environment to become too fragile. An otherwise well-coded system can be let down by one poorly coded program.
2. Hard to stop tasks after they start
Once an operation is underway there won’t be an opportunity to suspend that thread. It will continue to draw from the CPU’s resources until the operation is complete. This can cause major interruptions to processes if there is an error in the thread.
The user will need to manually stop the operations in order to restore the CPU so it can start working on other tasks. Preemptive multitasking can avoid this by interrupting applications and changing control.
3. Hard to ensure every task has access to the CPU
Each task will need to use the CPU for a certain amount and since these tasks are operating individually it’s impossible to guarantee access to the processing power. This will require manual intervention if certain tasks aren’t getting the time they need with the CPU.
This causes projects to take longer to complete and it means the user will have to routinely review things to make sure operations are running.
4. Not a good system for all response times
If you are dealing with response times in milliseconds or microseconds then you should consider a different type of system. Unfortunately, cooperative micro-tasking doesn’t work well at this level but if your response times are more generous it should be okay.
Conclusion
If you’re interested in a cooperative multitasking system then you should make sure it can suit your needs. As long as you’re a single user who has a small number of tasks, this system is ideal. However, in most instances, you will be better off using preemptive multitasking systems.
Although it is not commonly used with modern systems there is still some utility with cooperative multitasking. Certain systems such as JES2 and CICS are known for using this method. It can also be incredibly useful when you’re using embedded devices that naturally have memory constraints.
It’s worth considering your multitasking options before settling on one. Make sure that you can get the most out of the CPU to ensure tasks are being completed quickly and efficiently.