Coder Social home page Coder Social logo

Comments (4)

ilg-ul avatar ilg-ul commented on June 9, 2024

For consistency reasons, I would also rename

osThreadId_t osThisThreadGetId (void);
osStatus_t osThisThreadYield (void);
__NO_RETURN void osThisThreadExit (void *exit_ptr);

Actually all functions that do not have a osThreadId_t parameter refer to the current thread.

In CMSIS++ all functions that refer to the current thread are part of the this_thread namespace (or are prefixed with os_this_thread_ in the C API).

from cmsis_5.

ReinhardKeil avatar ReinhardKeil commented on June 9, 2024

There are situations where you want to stop a certain operation, but you do not want to abort it. In this case the suspend is initiated by other threads.

from cmsis_5.

ilg-ul avatar ilg-ul commented on June 9, 2024

if the purpose is to interrupt a thread, then suspend() is probably the least effective method.

as explained in #67 (and#83), suspend() and resume() are the basic scheduler primitives, and their semantic is to remove/add the thread to the READY list, exposed as the SUSPENDED/READY thread state codes.

suspending a thread does not guarantee that it will be stoped, because immediately after suspend() a timeout may occur, and the thread will be resumed, or even an expected event may occur (if waiting on a semaphore, a post() occurs on interrupts, etc).

stopping/interrupting a thread is a different story (see #68) and, to happen in an orderly manner, requires a two way protocol: one thread requests the interruption and sets a flag, the interrupted thread checks the flag and, if set, aborts what it was doing, and clears the flag. this flag should also be checked by all blocking functions, to cancel the wait and return a specific EINTR code.

I don't know, there might be situations when one thread suspends another, but I would say this usage is the result of a poor design; normally a thread, when nothing to do, removes itself from the ready list and, when an event occurs, some other thread or interrupt puts it back into the ready list.

from cmsis_5.

JonatanAntoni avatar JonatanAntoni commented on June 9, 2024

We have updated the thread documentation.

It should be clear now that osThreadSuspend() removes the target thread from the ready list under all circumstances. The thread will be rescheduled after calling osThreadResume, not under any other condition. So a suspended thread should not be resumed on a timeout or a semaphore becoming available.

Btw: To leave it up to the user we decided not to restrict the context a thread can be suspend from. This might be due to a poor design. But we do not want to introduce arbitrary limits on API level.

Please be so kind and close this issue if your questions are answered so far.

from cmsis_5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.