Task priority problem.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
huxuelei
Member
Member
Posts: 35
Joined: Tue May 27, 2008 8:32 am

Task priority problem.

Post 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 .
itisiuk
Member
Member
Posts: 98
Joined: Mon Mar 24, 2008 1:46 pm

Re: Task priority problem.

Post 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?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Task priority problem.

Post 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...
Every good solution is obvious once you've found it.
z180
Member
Member
Posts: 32
Joined: Tue Mar 04, 2008 12:32 pm

Re: Task priority problem.

Post 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.
itisiuk
Member
Member
Posts: 98
Joined: Mon Mar 24, 2008 1:46 pm

Re: Task priority problem.

Post 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 :(
Post Reply