comp.lang.ada
 help / color / mirror / Atom feed
* Task Scheduling
@ 2007-01-07 14:28   jpluto
  2007-01-07 14:49 ` Ludovic Brenta
  2007-01-07 20:47 ` Jeffrey Creem
  0 siblings, 2 replies; 3+ messages in thread
From:   jpluto @ 2007-01-07 14:28 UTC (permalink / raw)
  To: comp.lang.ada



A questions please:

I am trying to solve a problem, and I am not sure how to code it.

For example, if I have three arbitrary tasks, task1 has a priority than 
task2.
Therefore, task1 will always preempt task2 and task3.

However, if task2 ran first and locked a shared data resource that is shared 
with ONLY task3 and NOT task1.  Then if task1 arrives, I want task1 to yield 
the processor to task2 until task2 is finished using the resource even 
though task1 has the highest priority.

The problem, task1 has a higher priority and does NOT use this shared 
resource.
How can I ask this task1 not to run, and to wait whenever this shared 
resource is locked by task2 or task3?

If you cannot think of a solution, then is there a way to use Timing Events 
to stop task1 whenever it is running? If so, could you show me the code to 
do it?

I do not think this would be a great solution since there is an overhead of 
context switching since task1 is run and we have then to tell it to stop, 
but at least if you can help, it is still a solution to my problem.

Thank you very much
Jane

_________________________________________________________________
Get FREE Web site and company branded e-mail from Microsoft Office Live 
http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Task Scheduling
  2007-01-07 14:28 Task Scheduling   jpluto
@ 2007-01-07 14:49 ` Ludovic Brenta
  2007-01-07 20:47 ` Jeffrey Creem
  1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Brenta @ 2007-01-07 14:49 UTC (permalink / raw)


jpluto writes:
> A questions please:
>
> I am trying to solve a problem, and I am not sure how to code it.
>
> For example, if I have three arbitrary tasks, task1 has a priority
> than task2.
> Therefore, task1 will always preempt task2 and task3.
>
> However, if task2 ran first and locked a shared data resource that is
> shared with ONLY task3 and NOT task1.  Then if task1 arrives, I want
> task1 to yield the processor to task2 until task2 is finished using
> the resource even though task1 has the highest priority.
>
> The problem, task1 has a higher priority and does NOT use this shared
> resource.
> How can I ask this task1 not to run, and to wait whenever this shared
> resource is locked by task2 or task3?
>
> If you cannot think of a solution, then is there a way to use Timing
> Events to stop task1 whenever it is running? If so, could you show me
> the code to do it?
>
> I do not think this would be a great solution since there is an
> overhead of context switching since task1 is run and we have then to
> tell it to stop, but at least if you can help, it is still a solution
> to my problem.
>
> Thank you very much
> Jane

So, task1 does not use the shared resource, but must wait while task2
uses the shared resource, right?  I'm not sure I understand why this
is so.  I suspect a design flaw, but cannot tell for sure.  Could you
please explain why task1 needs to block at all, if it doesn't use the
shared resource?

Anyway, it seems that priority ceiling locking (see ARM D.3) would do
what you want, but only on a uniprocessor machine.

* task1 would have priority 2.
* task2 and task3 would have priority 1.
* The protected object would have priority 3, and use priority ceiling
  locking.

While task2 or task3 holds the protected object, they inherit priority
3 from the protected object, and therefore task1 cannot preempt them.

An alternative, working on both uniprocessors and multiprocessors,
would be for task2 to call Ada.Asynchronous_Task_Control.Hold to stop
task1, and Ada.Asynchronous_Task_Control.Continue to resume it.  But
that reeks of a design flaw, as I said above.

HTH

-- 
Ludovic Brenta.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Task Scheduling
  2007-01-07 14:28 Task Scheduling   jpluto
  2007-01-07 14:49 ` Ludovic Brenta
@ 2007-01-07 20:47 ` Jeffrey Creem
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Creem @ 2007-01-07 20:47 UTC (permalink / raw)


  jpluto wrote:
> 
> 
> A questions please:
> 
> I am trying to solve a problem, and I am not sure how to code it.
> 
> For example, if I have three arbitrary tasks, task1 has a priority than 
> task2.
> Therefore, task1 will always preempt task2 and task3.
> 
> However, if task2 ran first and locked a shared data resource that is 
> shared with ONLY task3 and NOT task1.  Then if task1 arrives, I want 
> task1 to yield the processor to task2 until task2 is finished using the 
> resource even though task1 has the highest priority.
> 
> The problem, task1 has a higher priority and does NOT use this shared 
> resource.
> How can I ask this task1 not to run, and to wait whenever this shared 
> resource is locked by task2 or task3?

I can't really think of a way. What you are asking for really seems 
quite odd and seems like a very strange way to abuse the priority system.

It sounds like what you 'really' want to do is to have dynamic 
priorities on tasks 2 and 3 such that whenever they 'have' the shared 
resource, they elevate their priority higher than task 1.

Have you considered just building the code that controls access to the 
resource such that it uses Ada.Dynamic_Priorities to capture initial 
priority, raise it up while the resource is held and then restore it 
when the resource is done....Or something like that?



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-07 20:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-07 14:28 Task Scheduling   jpluto
2007-01-07 14:49 ` Ludovic Brenta
2007-01-07 20:47 ` Jeffrey Creem

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox