comp.lang.ada
 help / color / mirror / Atom feed
From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject: Re: STM32F4 Discovery, communication and libraries
Date: Wed, 10 Sep 2014 09:05:38 -0400
Date: 2014-09-10T09:05:38-04:00	[thread overview]
Message-ID: <80i01atqat8hrftl7lqeodf9psshlbqnk3@4ax.com> (raw)
In-Reply-To: b8623ccb-c374-4c50-bc77-fdb9bd255846@googlegroups.com

On Wed, 10 Sep 2014 01:52:27 -0700 (PDT), Roy Emmerich
<roy.emmerich@gmail.com> declaimed the following:

>Dennis thanks for your feedback. It is really helping to think of alternative ways to achieve my goal.
>
>On Wednesday, 10 September 2014 03:41:16 UTC+2, Dennis Lee Bieber  wrote:
>> 	I suspect all you really need is a scheduler based on a priority queue
>> -- in which the "priority" is really the time-of-next-event... Closest
>> event is in front. Presuming you initialize all the devices before starting
>> the scheduler there should not be any problem of a suddenly an event crops
>> up that needs to go "now".
>
>When you say scheduler, is this some specific Ada construct? I have a simple array in mind, or maybe a linkedlist/hashmap (i.e. key/value pairs) with time-of-next-event as the key and values being references to the device handlers.
>
	If it helps, change "scheduler" to "dispatcher".

	"Sorting" is done by the operation to insert an event into the queue.
Inserting an entry would be done by traversing the queue from the front,
and as soon as you find an entry that has an event time that falls after
the new event being inserted you've found the position. (Of course, if you
reach the end of the queue, then the item goes on the end <G>)

	Suggest a linked list with extension. That is, the top level record has
no data, only the event time and the link to the next/previous entries.
Each distinct device class would extend the node with parameters specific
to that device.

	The queue/linked-list management and dispatcher only need to see the
links and event time to control the order. The dispatcher would have to be
able to invoke the proper process based on the extended type (I'd have to
study my books for this -- "Ada for Software Engineers, 2nd Ed" (Ben-Ari,
2009 Springer-Verlag) section 6.7 is a linked list priority queue (intro,
not fully developed), 12.2.1 introduces call-backs.

>How I understand it is the scheduler sorts all events by time whenever a new event is added to the queue. What happens when two events have the same time-of-next-event? Introduce a second priority level?
>
	The insert logic puts them in the order they arrived (so something that
has been waiting longer will get run before a fast-cycle event that has run
and requeued).

>There will also be house keeping tasks such as syncing the on-board RTC to the GPS time. I am thinking of scheduling these based on time (e.g. once a day) but having a higher priority than the rest of the logging tasks. An additional priority level could be useful in this case. However, having said that, it isn't absolutely critical for the time sync to occur at a particular time. This is getting me thinking about time windows. In other words, do this task at least once a day, at this time +-5 minutes. In terms of RTC syncing this won't help much if you are logging something every second as it takes much longer for the GPS receiver to start up and lock on, in which case a variable being logged every second would just have to wait until the GPS syncing has finished, leaving a gap in the logged data. One could get more sophisticated and get the GPS sync event to have various states (e.g. first start the GPS receiver then wait in the queue until a valid signal is available, allowing

	No real "priority" levels in this scheme -- the scheduled event time is
the only priority.

	You delay until the time of the next event, process that event (which
is then responsible for putting /its/ next invocation onto the queue), go
back and do the next event on the queue (always the front of queue).

	If multiples end up on the same event time, you basically process them
in order without a delay, only when the event time is greater than "now" do
you need to delay until xxx. Since each event process is in charge of
scheduling its next invocation, there is no way an event could suddenly end
up at the front of the queue while you are delaying (all other events are
already on the queue, and the event to be processed can't add itself until
it runs).


	I'm late for work... Hope this helps.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/


  reply	other threads:[~2014-09-10 13:05 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26 22:38 STM32F4 Discovery, communication and libraries roy.emmerich
2014-08-27  2:40 ` Luke A. Guest
2014-08-27 12:35   ` Roy Emmerich
2014-08-27  7:41 ` Dmitry A. Kazakov
2014-08-27 13:35   ` Roy Emmerich
2014-08-27 16:00     ` Dmitry A. Kazakov
2014-08-27 13:08 ` Dennis Lee Bieber
2014-08-27 15:44   ` Roy Emmerich
2014-08-28  1:37     ` Dennis Lee Bieber
2014-08-27 16:03   ` Roy Emmerich
2014-08-28  1:48     ` Dennis Lee Bieber
2014-08-28 10:12       ` Roy Emmerich
2014-08-28 13:00         ` Dmitry A. Kazakov
2014-08-28 16:28           ` Mike Silva
2014-08-28 17:03             ` Roy Emmerich
2014-08-28 20:09             ` Dmitry A. Kazakov
2014-08-28 20:34               ` embeddedrelatedmike
2014-08-29  7:34                 ` Dmitry A. Kazakov
2014-08-29 15:59                   ` Niklas Holsti
2014-08-29 16:59                     ` [OT] Ravenscar (the place, not profile), was: " Simon Clubley
2014-08-29 17:18                       ` Niklas Holsti
2014-08-29 17:31                         ` Simon Clubley
2014-08-30 14:55                           ` Dennis Lee Bieber
2014-08-29 17:59                       ` Jeffrey Carter
2014-08-29 23:30                       ` Randy Brukardt
2014-08-30 11:25                         ` Simon Clubley
2014-08-31 11:09                           ` Phil Thornley
2014-08-30 12:36                         ` Peter Chapin
2014-08-31 18:37                         ` Dirk Craeynest
2014-08-31 19:38                           ` Simon Clubley
2014-08-29 17:24                   ` Mike Silva
2014-08-29 23:35                     ` Randy Brukardt
2014-08-29 13:06                 ` Dennis Lee Bieber
2014-08-29 16:52                   ` Niklas Holsti
2014-08-31  0:49                     ` Shark8
2014-08-28 21:17               ` Niklas Holsti
2014-08-29  0:07                 ` Roy Emmerich
2014-08-29 17:58                   ` Niklas Holsti
2014-08-29  7:41                 ` Dmitry A. Kazakov
2014-08-29 16:31                   ` Niklas Holsti
2014-08-29 16:47                     ` Roy Emmerich
2014-08-29 19:41                       ` Niklas Holsti
2014-08-30 22:00                         ` Roy Emmerich
2014-08-31 10:08                           ` Simon Wright
2014-09-01 20:15                           ` Niklas Holsti
2014-09-01 21:11                             ` Jeffrey Carter
2014-08-31  4:54                       ` gvdschoot
2014-09-09 19:17                         ` Roy Emmerich
2014-09-09 20:20                           ` Mike Silva
     [not found]                             ` <a54dcc42-d4e2-4d53-b381-2bb7a0eef1ee@googlegroups.com>
2014-09-10  1:41                               ` Dennis Lee Bieber
2014-09-10  8:52                                 ` Roy Emmerich
2014-09-10 13:05                                   ` Dennis Lee Bieber [this message]
2014-09-10 17:16                                     ` Simon Wright
     [not found]                               ` <a2e59fce-751c-46a0-90f3-80430c627732@googlegroups.com>
2014-09-10  7:22                                 ` Dmitry A. Kazakov
2014-09-10  9:35                                 ` Roy Emmerich
2014-09-10 14:11                               ` Stephen Leake
2014-09-10 17:46                                 ` Jeffrey Carter
2014-09-10 18:37                                   ` Dmitry A. Kazakov
2014-09-11  9:53                                   ` Stephen Leake
2014-09-11 17:19                                     ` Jeffrey Carter
2014-09-10 20:58                               ` Brian Drummond
2014-09-10 23:40                                 ` Dennis Lee Bieber
2014-08-29 16:58                     ` Niklas Holsti
2014-08-31  7:02                     ` Dmitry A. Kazakov
2014-08-31 15:44                       ` Brad Moore
2014-08-31 16:15                         ` Dmitry A. Kazakov
2014-09-01 16:15                           ` Brad Moore
2014-09-01 16:42                             ` Dmitry A. Kazakov
2014-08-31 18:41                       ` Niklas Holsti
2014-09-01 16:42                         ` Dmitry A. Kazakov
2014-09-01 17:21                           ` G.B.
2014-09-02  8:21                             ` Dmitry A. Kazakov
2014-09-02 13:04                               ` G.B.
2014-09-02 14:18                                 ` Dmitry A. Kazakov
2014-09-02 16:44                               ` Jeffrey Carter
2014-09-02 19:02                                 ` Niklas Holsti
2014-09-02 23:19                               ` Randy Brukardt
2014-09-03  1:40                                 ` gdotone
2014-09-04  9:26                                   ` Roy Emmerich
2014-09-04 17:58                                     ` Niklas Holsti
2014-09-05 11:47                                       ` Simon Clubley
2014-09-09 19:04                                         ` Roy Emmerich
2014-09-01 18:39                           ` Niklas Holsti
2014-09-02  8:19                             ` Dmitry A. Kazakov
2014-08-28 13:10         ` Dennis Lee Bieber
2014-08-29  2:52           ` Dennis Lee Bieber
2014-09-20 20:50   ` David Thompson
2014-08-27 16:17 ` Mike Silva
2014-08-27 16:36   ` Roy Emmerich
2014-08-27 16:58     ` Simon Clubley
2014-08-29 19:36 ` johnscpg
2014-08-30 15:06   ` Stephen Leake
2014-09-02 21:40 ` rrr.eee.27
replies disabled

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