FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [October 2004 Threads] Thread self referencePosted by Nobody/Anonymous on October 28, 2004 Hi,
How can I get the xTaskHandle for the current running thread?
Regards Henric
RE: Thread self referencePosted by Richard on October 28, 2004 Why do you want to do this? Functions such as vTaskSuspend( xTaskHandle) will suspend the currently executing task if NULL is passed in as the parameter. There may be a way around what you are wanting to do like this.
The xTaskHandle is just a pointer to the task control block. It's type is hidden outside of tasks.c though (it is void* outside of tasks.c). You can obtain it by adding the following function to tasks.c (I haven't tried compiling this so watch out for typos):
xTaskHandle xGetCurrentTaskHandle( void ) { xTaskHandle xReturn;
portENTER_CRITICAL(); xReturn = ( xTaskHandle ) pxCurrentTCB; portEXIT_CRITICAL();
return xReturn; }
An alternative and not very nice hack would be to simply declare:
extern volatile void * volatile pxCurrentTCB;
at the top of your application file. pxCurrentTCB will then be the handle to the currently executing task. This may cause a linker warning though and access to the extern variable would have to be only within critical regions so the first method is preferable.
RE: Thread self referencePosted by Nobody/Anonymous on October 29, 2004 Hi,
Thanks for a great RTOS. I'll try the function xGetCurrentTaskHandle().
The first reason for I need this is that our software is message based, and each message has a sender and a receiver (UML state machines). Thus, I need to know the sender's task handle when creating the message. The second is that the passive objects often use the task handle as an unique reference.
Also, the software is not all new code. It contains lots of old code written for pSOS, OSE, and eCos. Those OSes has a self reference function, and since this functions is used... well, sigh...
Best Regards Henric
Hello Henric !!! (UML state machines)Posted by Nobody/Anonymous on November 30, 2004 Hello, Are u aware of Dr. Miro Samek QF (quantum frame work) or have you tried replacing UML state machines with QF. If so please share u'r experience.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|