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 .
Task priority problem.
Re: Task priority problem.
what about a yield function so that
when task 1 had finished what its doing it yields and passes control to the next task?
when task 1 had finished what its doing it yields and passes control to the next task?
Re: Task priority problem.
@ 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...
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...
Every good solution is obvious once you've found it.
Re: Task priority problem.
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.
didnt realise it was cooperative multitasking.What you mention there is called "cooperative multitasking". Works only as long as all apps are well-behaved.
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