Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #27953
| From | Niklas Holsti <niklas.holsti@tidorum.invalid> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: "Boost context" for task switching on embedded Linux on ARM |
| Date | 2018-08-06 22:48 +0300 |
| Organization | Tidorum Ltd |
| Message-ID | <fsrn0dFgqdgU1@mid.individual.net> (permalink) |
| References | (5 earlier) <ed5d0694-786b-4e30-a4e6-80f853ca277f@googlegroups.com> <d8c82ce1-b784-4cd7-bef2-d8c713a752d9@googlegroups.com> <52566ade-3dcc-43b0-ae3a-707cfc93d8f3@googlegroups.com> <j80gmd5mmlrvh8o99uh2va8kjolkh8bv39@4ax.com> <87pnyvgxuk.fsf@nightsong.com> |
On 18-08-06 21:21 , Paul Rubin wrote:
> George Neuner <gneuner2@comcast.net> writes:
>> Multi-tasking with [setjmp/jmp_buf] is another issue. It's generally
>> pretty easy to set up a new stack, but initializing all the other CPU
>> state for the new "task" can be problematic. It was easier to do with
>> simpler CPUs. It still can be done with a modern CPU, but it is much
>> more difficult to get everything right [the more so for lack of
>> documentation].
>
> This sounds pretty horrendous and compiler and hardware dependent. You
> are basically writing a miniature OS in your scheduler. It helps if the
> compiler docs explicitly say it's supposed to work. Otherwise, if you
> reverse engineer it for a particular compiler version, all bets are off
> for the next one.
>
> There are some very lightweight RTOS out there and it's probably saner
> to just use one instead of a hack like this.
Simplest robust solution I can think of is to create one semaphore for
each of the round-robin threads, initialise all semaphores but one to
zero, and initialise the semaphore for the first thread that you want to
run, to one (1).
Each thread starts with "taking" its own semaphore, which means that
only the chosen "first thread" actually starts running, and the other
threads all block on their semaphores. When a thread wants to yield to
some other thread, it calls a function that:
- "signals" the semaphore for the thread that should run next (how ever
you want to choose that thread), and then
- "takes" the semaphore for the current thread (the one that is
yielding), which blocks this thread until someone signals this semaphore.
In this way, you can implement either round-robin execution or
"directed" yields to a specific thread, because you control which
semaphore is signalled next.
Assuming that the base system is Linux, or some competent RTOS, I would
never mess around with jmp_buf or some system-dependent threading libraries.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
"Boost context" for task switching on embedded Linux on ARM gp.kiwi@gmail.com - 2018-08-03 05:52 -0700
Re: "Boost context" for task switching on embedded Linux on ARM George Neuner <gneuner2@comcast.net> - 2018-08-04 03:28 -0400
Re: "Boost context" for task switching on embedded Linux on ARM Niklas Holsti <niklas.holsti@tidorum.invalid> - 2018-08-04 11:13 +0300
Re: "Boost context" for task switching on embedded Linux on ARM George Neuner <gneuner2@comcast.net> - 2018-08-04 07:08 -0400
Re: "Boost context" for task switching on embedded Linux on ARM George Neuner <gneuner2@comcast.net> - 2018-08-04 07:22 -0400
Re: "Boost context" for task switching on embedded Linux on ARM graeme.prentice@gmail.com - 2018-08-04 04:49 -0700
Re: "Boost context" for task switching on embedded Linux on ARM "gp...@gmail.com" <graeme.prentice@gmail.com> - 2018-08-04 05:25 -0700
Re: "Boost context" for task switching on embedded Linux on ARM graeme.prentice@gmail.com - 2018-08-04 06:01 -0700
Re: "Boost context" for task switching on embedded Linux on ARM George Neuner <gneuner2@comcast.net> - 2018-08-06 04:17 -0400
Re: "Boost context" for task switching on embedded Linux on ARM Paul Rubin <no.email@nospam.invalid> - 2018-08-06 11:21 -0700
Re: "Boost context" for task switching on embedded Linux on ARM Niklas Holsti <niklas.holsti@tidorum.invalid> - 2018-08-06 22:48 +0300
Re: "Boost context" for task switching on embedded Linux on ARM gp.kiwi@gmail.com - 2018-08-07 04:43 -0700
Re: "Boost context" for task switching on embedded Linux on ARM George Neuner <gneuner2@comcast.net> - 2018-08-07 15:10 -0400
Re: "Boost context" for task switching on embedded Linux on ARM Niklas Holsti <niklas.holsti@tidorum.invalid> - 2018-08-07 22:41 +0300
Re: "Boost context" for task switching on embedded Linux on ARM George Neuner <gneuner2@comcast.net> - 2018-08-08 00:42 -0400
Re: "Boost context" for task switching on embedded Linux on ARM Niklas Holsti <niklas.holsti@tidorum.invalid> - 2018-08-08 08:21 +0300
Re: "Boost context" for task switching on embedded Linux on ARM George Neuner <gneuner2@comcast.net> - 2018-08-09 10:55 -0400
Re: "Boost context" for task switching on embedded Linux on ARM Niklas Holsti <niklas.holsti@tidorum.invalid> - 2018-08-09 22:14 +0300
Re: "Boost context" for task switching on embedded Linux on ARM George Neuner <gneuner2@comcast.net> - 2018-08-06 04:04 -0400
Re: "Boost context" for task switching on embedded Linux on ARM gp.kiwi@gmail.com - 2018-08-06 04:09 -0700
Re: "Boost context" for task switching on embedded Linux on ARM George Neuner <gneuner2@comcast.net> - 2018-08-06 12:29 -0400
csiph-web