removing taskvares (was Re: rtems_filesystem_current issues)
Chris Johns
cjohns at cybertec.com.au
Mon Oct 28 04:06:23 UTC 2002
Eric Norum wrote:
>
> For example, here's the task-variable support code in the task context
> switch (in rtems/src/tasks.c) that would be removed.
>
Yes. The same goes for ASR and POSIX signals. I have a solution in mind
for all these, but that is something for another day.
>
> Sure it's only a
> couple of tests and conditional branches if neither task uses task
> variables, but this is a very heavily-used piece of code......
It is worse, as this code runs as part of another loop of switch
handlers. My aim is all this overhead goes including the top loop.
>
> Can you expand a little on how you see RPC being supported?
>
I have not looked into the RPC code any further than the couple of files
meantioned here. I do not know the exact tasking structure, but this
sort of change is a start and I hope shows how things can be made to work.
Change cpukit/librpc/src/rpc/rtems_rpc.c with something like:
static RTEMS_BOOLEAN has_extension;
rtems_id rpc_extension_id;
int rtems_rpc_extension_index;
static rtems_extension
rtems_rpc_delete_task (rtems_tcb* current_task,
rtems_tcb* deleted_task)
{
/* what ever is needed here, something like ... */
void* rpc_vars =
rtems_get_tcb_task_ext(deleted_task,
rtems_rpc_extension_index);
if (rpc_vars)
{
free (rpc_vars);
}
}
static rtems_extension
rtems_rpc_exitted_task (rtems_tcb* exitted_task)
{
/* what ever is needed here, something like ... */
void* rpc_vars =
rtems_get_tcb_task_ext(exitted_task,
rtems_rpc_extension_index);
if (rpc_vars)
{
free (rpc_vars);
}
}
int rtems_rpc_task_init (void)
{
if (!has_extension)
{
/* this can be and should be local */
rtems_extensions_table rpc_extensions;
rpc_extensions.thread_create = NULL;
rpc_extensions.thread_start = NULL;
rpc_extensions.thread_restart = NULL;
rpc_extensions.thread_delete = rtems_rpc_delete_task;
rpc_extensions.thread_switch = NULL;
rpc_extensions.thread_begin = NULL;
rpc_extensions.thread_exitted = rtems_rpc_exitted_task;
rpc_extensions.fatal = NULL;
rtems_extension_create (rtems_build_name ('R', 'P', 'C', 'v'),
&rpc_extensions, &rpc_extension_id);
rtems_rpc_extension_index =
rtems_get_index(rpc_extension_id);
has_extension = 1;
}
}
Then change cpukit/librpc/include/rpc/rpc.h:
extern int rtems_rpc_extension_index;
#define rtems_rpc_task_variables \
(rtems_get_self_task_ext(rtems_rpc_extension_index))
which turns into:
_Executing_Thread->extensions[rtems_rpc_extension_index]
The extensions plus index calculations uses a few more cycles than I
would have liked, but I cannot see a leaner way.
The RTEMS reent structure would have a similar macro.
--
Chris Johns, cjohns at cybertec.com.au
More information about the users
mailing list