Page 1 of 1

Task priority problem.

Posted: Mon Aug 11, 2008 1:55 am
by huxuelei
Hi.
I have three task: task1,task2,task3.There priority is 14, 15, 16, task1's priority(14) is highest.These task is scheduled through priority policy, that is task1 always run first.
These three task will access a memory buffer- Buffer1.Before they write to or read from the memory buffer, they must try to obtain a binary sempahore.
Now I have a trouble, task1 runs too fast, which cause other task(task2, task3)can never access the memory buffer.

How can I solve this problem?I want these three task can run when they need to .

Re: Task priority problem.

Posted: Mon Aug 11, 2008 6:36 am
by itisiuk
what about a yield function so that
when task 1 had finished what its doing it yields and passes control to the next task?

Re: Task priority problem.

Posted: Mon Aug 11, 2008 8:23 am
by Solar
@ huxuelei:

There are many different approaches to this, most of them discussed in relevant books on OS theory. Search for "Scheduling algorithms", or "Priority degradation" for example, and continue from there. I'd suggest you at least skim them all to decide which one is appropriate for you. Some algorithms focus on throughput, others on minimum latency, some are excellent on single-CPU systems but suck on multicores, etc. etc.

@ itisiuk:

What you mention there is called "cooperative multitasking". Works only as long as all apps are well-behaved...

Re: Task priority problem.

Posted: Mon Aug 11, 2008 9:33 am
by z180
multitasking sucks in windows 3.xx because there is simple preemptive multtasking between dos boxes,and all win apps share ONE of these.

Re: Task priority problem.

Posted: Mon Aug 11, 2008 9:37 am
by itisiuk
What you mention there is called "cooperative multitasking". Works only as long as all apps are well-behaved.
didnt realise it was cooperative multitasking.
i just thought i was a good idea when i was writing my os.

found out the hard way too, when i started to load programs and they wernt very well behaved at all.
had a massive problem with deadlocking when accessing devices.
fixed it now but having to re-write most of my drivers :(