Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-07

QueueAsyncCall() scheduling

11 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

I note (now :-) that QueueAsyncCall() works on a strictly LIFO basis, i.e. it's really a stack rather than a queue.

Has anybody ever built a simple round-robin scheduler based on this, for example to handle low-speed comms on an indeterminate number of serial ports?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Martin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 7 lines
I note (now :-) that QueueAsyncCall() works on a strictly LIFO basis, i.e. it's really a stack rather than a queue. Has anybody ever built a simple round-robin scheduler based on this, for example to handle low-speed comms on an indeterminate number of serial ports?

Which revision of lazarus? IIRC it was very recently changed (corrected) to FIFO.

Reply by email

Mark Morgan Lloyd
to Martin
Martin wrote 10 lines
On 17/07/2010 13:36, Mark Morgan Lloyd wrote: > I note (now :-) that QueueAsyncCall() works on a strictly LIFO basis, > i.e. it's really a stack rather than a queue. > > Has anybody ever built a simple round-robin scheduler based on this, > for example to handle low-speed comms on an indeterminate number of > serial ports? > Which revision of lazarus? IIRC it was very recently changed (corrected) to FIFO.

0.9.28.3. I saw the discussion from earlier in the year, but I was specifically considering code that could handle several serial ports pseudo-concurrently while being able to display messages etc. using visual controls. Obviously I could go for a full-blooded multithreaded solution, but async calls work very well for one port at a time...

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Martin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 18 lines
Martin wrote: > On 17/07/2010 13:36, Mark Morgan Lloyd wrote: >> I note (now :-) that QueueAsyncCall() works on a strictly LIFO >> basis, i.e. it's really a stack rather than a queue. >> >> Has anybody ever built a simple round-robin scheduler based on this, >> for example to handle low-speed comms on an indeterminate number of >> serial ports? >> > Which revision of lazarus? IIRC it was very recently changed > (corrected) to FIFO. 0.9.28.3. I saw the discussion from earlier in the year, but I was specifically considering code that could handle several serial ports pseudo-concurrently while being able to display messages etc. using visual controls. Obviously I could go for a full-blooded multithreaded solution, but async calls work very well for one port at a time...

Maybe look at trunk, I don't know if that ever went into any branch.

Revision: 25698
Date: 16:29:53, 27 May 2010
Message: Change ASyncQueue to run in forward order (first in / first out)

Reply by email

waldo kitty
to Mark Morgan Lloyd: I note (now :-) that QueueAsyncCall() works on a strictly LIFO basis, i.e. it's really a…
Mark Morgan Lloyd wrote
I note (now :-) that QueueAsyncCall() works on a strictly LIFO basis, i.e. it's really a stack rather than a queue.

hunh? i thought a queue was an orderly format already... just like a stack... like getting in the queue to get on the metro or to enter the stadium to see your favorite band or to even buy lunch ;)

i must admit that i don't see the apparent difference :?

Has anybody ever built a simple round-robin scheduler based on this, for example to handle low-speed comms on an indeterminate number of serial ports?

i haven't, yet :P

Reply by email

Mark Morgan Lloyd
to waldo kitty
waldo kitty wrote 5 lines
hunh? i thought a queue was an orderly format already... just like a stack... like getting in the queue to get on the metro or to enter the stadium to see your favorite band or to even buy lunch ;) i must admit that i don't see the apparent difference :?

So I take it you'd be happy if the last person to join the queue was always the first to be served, possibly taking the place of somebody currently /being/ served. Whatever, that aspect is apparently being changed.

Show quoted text 5 lines
> Has anybody ever built a simple round-robin scheduler based on this, > for example > to handle low-speed comms on an indeterminate number of serial ports? i haven't, yet :P

I'm planning a crude hack, hopefully just a list of TDataEvent with control being distributed by a shim in a single async call procedure. However I've got some system management work that's intruding...

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Martin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 11 lines
>> Has anybody ever built a simple round-robin scheduler based on this, >> for example >> to handle low-speed comms on an indeterminate number of serial ports? > > i haven't, yet :P I'm planning a crude hack, hopefully just a list of TDataEvent with control being distributed by a shim in a single async call procedure. However I've got some system management work that's intruding...

You did see my mail, that this was changed in Revision 25698?

So you can now, use QueueAsyncCall to *queue* several events, for several comms, and they will be executed first-in, first-out.

Martin

Reply by email

Mark Morgan Lloyd
to Martin
Martin wrote
You did see my mail, that this was changed in Revision 25698? So you can now, use QueueAsyncCall to *queue* several events, for several comms, and they will be executed first-in, first-out.

Yes, I did. And if I understand things correctly each will be executed to completion, first in first out, so it's not very much help for something that needs to loop.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Martin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 11 lines
Martin wrote: > You did see my mail, that this was changed in Revision 25698? > > So you can now, use QueueAsyncCall to *queue* several events, for > several comms, and they will be executed first-in, first-out. Yes, I did. And if I understand things correctly each will be executed to completion, first in first out, so it's not very much help for something that needs to loop.

Well each called function/procedure must voluntary return anyway (if you do not use threads). So if a method returns, it just adds itself to the end of the list again => and that way you keep looping.

I've done exactly that myself (but with only one method), instead of ProcessMessages, the method reschedules itself.

Reply by email

Mark Morgan Lloyd
to Martin
Martin wrote 6 lines
Well each called function/procedure must voluntary return anyway (if you do not use threads). So if a method returns, it just adds itself to the end of the list again => and that way you keep looping. I've done exactly that myself (but with only one method), instead of ProcessMessages, the method reschedules itself.

Yes, I agree that that's probably a valid way of implementing it.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

waldo kitty
to Mark Morgan Lloyd: So I take it you'd be happy if the last person to join the queue was always the first to…
Mark Morgan Lloyd wrote 11 lines
waldo kitty wrote: > hunh? i thought a queue was an orderly format already... just like a stack... > like getting in the queue to get on the metro or to enter the stadium to see > your favorite band or to even buy lunch ;) > > i must admit that i don't see the apparent difference :? So I take it you'd be happy if the last person to join the queue was always the first to be served, possibly taking the place of somebody currently /being/ served. Whatever, that aspect is apparently being changed.

yeah, it was later that i caught the LIFO vs FIFO flow... my above is mainly that a stack and a queue are, at least to me, the same but then i always do FIFO except in extremely rare cases...

Show quoted text 8 lines
>> Has anybody ever built a simple round-robin scheduler based on this, for example >> to handle low-speed comms on an indeterminate number of serial ports? > > i haven't, yet :P I'm planning a crude hack, hopefully just a list of TDataEvent with control being distributed by a shim in a single async call procedure. However I've got some system management work that's intruding...

don'cha hate it when that happens? ;)

Reply by email