How to implement multitasking?
How to implement multitasking?
My current project is a simple 16-bit real mode OS without multitasking, though I am interested, how to implement it? (multitasking) Is there any CPU level way to execute two binaries at same time?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
Re: How to implement multitasking?
Search the forums. This has been discussed in depth before!
I think the short version is that this is cracy, real mode is obsolete, you are wasting your time, use a 32 bit or 64 mode.
I think the short version is that this is cracy, real mode is obsolete, you are wasting your time, use a 32 bit or 64 mode.
- Bender
- Member
- Posts: 449
- Joined: Wed Aug 21, 2013 3:53 am
- Libera.chat IRC: bender|
- Location: Asia, Singapore
Re: How to implement multitasking?
Multitasking as I see it, isn't really multitasking, Multitasking I think doesn't exist at all, IMO multitasking is a way to fool the user that two tasks are running simultaneously, but they are not. I think you use a timer interrupt or a keyboard interrupt (depending upon your design) to switch tasks. Each task must be given a specific period of time (preemptive), if you set the PIT (you can also use the RTC Interrupt, but that's not accurate as PIT) to say 10hz then each task will be given a period of 0.1 seconds, the CPU will switch tasks after every 0.1 seconds. Remember to save the registers of the tasks before switching to a new task.
Say you have two tasks A and B, both the tasks print numbers from 0 to infinity, Both start at the same time, now every timer tick (assuming you've used a timer) the CPU will switch between these tasks, and it'll be so quick for our eyes to notice.....
PS. I am in sleep mode writing this so I may have missed something.
Say you have two tasks A and B, both the tasks print numbers from 0 to infinity, Both start at the same time, now every timer tick (assuming you've used a timer) the CPU will switch between these tasks, and it'll be so quick for our eyes to notice.....
PS. I am in sleep mode writing this so I may have missed something.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
(R3X Runtime VM)(CHIP8 Interpreter OS)
Re: How to implement multitasking?
Since more than thirty years ago there exist multi-processor machines. Two tasks can be running simultaneously on different cpu.Bender wrote:Multitasking as I see it, isn't really multitasking, Multitasking I think doesn't exist at all, IMO multitasking is a way to fool the user that two tasks are running simultaneously, but they are not.
By the way, the world has defined multi-tasking in a bit different than yours. To get start, check cooperative multi-tasking - it IS called multitasking even they do not run simultaneously.