thread number
Chris Johns
chrisj at rtems.org
Fri Apr 22 10:52:53 UTC 2005
Manuel Pedro Coutinho wrote:
>
> I'm developing an application that needs to attribue a number to each
> task. I guess the easyest way to do this is by getting the information
> from the task id:
> rtems_get_index(id)
>
> My question is if the index number of the id are sequencial, that is,
> the index number is increased as the tasks are created...
The tasks are score threads and these are based on the standard score
object. If you look in _Objects_Initialize_information:
cpukit/score/src/objectinitializeinformation.c
you will see the object table is extended by the default size. If you
look in _Objects_Extend_information:
cpukit/score/src/objectextendinformation.c
you will see:
_Chain_Append( &information->Inactive, &the_object->Node );
This places the object onto the Inactive chain and just above you can
see the object id being created.
As tasks are created and deleted they are removed and placed onto the
Inactive object chain. This design helps give RTEMS its deterministic
behavior (no need to scan tables or check if an id is still being used).
The way in which your application uses tasks effects the order of the
list in relation to the object id.
> and what happens when a task is deleted, does that index becames
> available to next task create?
Depends. To complicate the ordering more the unlimited object code can
extend and shrink the object table based on the number of objects,
either adding more to the Inactive chain or removing a block including
the last one you just deleted.
I suggest you do not exploit any ordering or behavior you may find as a
change to this code could break your application.
--
Chris Johns
More information about the users
mailing list