Hi,
MrLolthe1st wrote:
I'm written multitasking for my own OS, it working ok, but i'm switching tasks when interrupt from PIT has thrown
Unfortunately, assuming task switches are caused by the timer IRQ and nothing else is a common mistake. I've even seen kernels where (e.g.) near the start of its time slice a process will call a function like "read()" and have to wait for data to arrive from disk, but the CPU will be left doing nothing for almost the entire time slice until a timer IRQ triggers a task switch; so about 99% of CPU time ends up being wasted.
The reality is that most task switches are caused by the currently running task blocking (e.g. needing to wait for data from another process, or from keyboard or network or disk or...), or are caused by something happening that a task was waiting for (especially when there were no other tasks running at the time or there's some kind of task priorities involved); and doing task switches when the timer IRQ occurs is just a relatively unimportant optional thing in case a task doesn't block sooner.
I guess what I'm saying is that you could set your timer to 1 Hz, and still get 1 million task switches per second between thousands of tasks.
Cheers,
Brendan