Permalink
Browse files

[component:os][component:templates][multicore] Each core has it own

tpl_resource_table that points to its res_scheduler (one res_scheduler per
core). The tpl_resource_table must be recovered using the TPL_RESOURCE_TABLE
macro.
  • Loading branch information...
KamelHacene committed Aug 3, 2016
1 parent d9eaba9 commit a28625f760a5b182321b2648f48773c7cebb0ec2
@@ -108,6 +108,7 @@ FUNC(tpl_app_id, OS_CODE) tpl_check_object_ownership_service(
{
VAR(tpl_app_id, AUTOMATIC) result = INVALID_OSAPPLICATION_ID;
VAR(StatusType, AUTOMATIC) result_status = E_OK;
GET_CURRENT_CORE_ID(core_id)
/* lock the kernel */
LOCK_KERNEL()
@@ -147,7 +148,7 @@ FUNC(tpl_app_id, OS_CODE) tpl_check_object_ownership_service(
#if RESOURCE_COUNT > 1
if (obj_id < RESOURCE_COUNT)
{
result = tpl_resource_table[obj_id]->app_id;
result = TPL_RESOURCE_TABLE(core_id)[obj_id]->app_id;
}
#endif
break;
View
@@ -54,12 +54,13 @@ FUNC(void, OS_CODE)
FUNC(void, OS_CODE)
print_rez(CONST(tpl_resource_id, AUTOMATIC) rez_id)
{
GET_CURRENT_CORE_ID(core_id)
#ifdef WITH_DOW /* not all ports have an stdc */
printf("resource %d (ceiling_prio=%d, owner_prio=%d)\n",
rez_id,
tpl_resource_table[rez_id]->ceiling_priority,
tpl_resource_table[rez_id]->owner_prev_priority);
printf(" owner=%d\n",tpl_resource_table[rez_id]->owner);
TPL_RESOURCE_TABLE(core_id)[rez_id]->ceiling_priority,
TPL_RESOURCE_TABLE(core_id)[rez_id]->owner_prev_priority);
printf(" owner=%d\n",TPL_RESOURCE_TABLE(core_id)[rez_id]->owner);
#endif /* defined WITH_DOW */
}
@@ -313,38 +313,116 @@ foreach resource in REGULARRESOURCES
template resource_descriptor
end foreach
if OS::USERESSCHEDULER then
%
/**
* The scheduler resource descriptor.
* One scheduler resource is defined per core.
*
* @see #RES_SCHEDULER
*/
%
loop core_id from 0 to OS::NUMBER_OF_CORES - 1 do
%
#define OS_START_SEC_VAR_UNSPECIFIED
#include "tpl_memmap.h"%
if OS::NUMBER_OF_CORES > 1 then%
VAR(tpl_resource, OS_VAR) res_sched_core% !core_id %_rez_desc = {%
else %
VAR(tpl_resource, OS_VAR) res_sched_rez_desc = {%
end if%
RES_SCHEDULER_PRIORITY, /* ceiling priority */
0, /* owner_prev_priority */
INVALID_PROC_ID, /* owner */
#if WITH_OSAPPLICATION == YES
INVALID_OSAPPLICATION_ID, /* OS Application id */
#endif
NULL /* next_res */
};
#define OS_STOP_SEC_VAR_UNSPECIFIED
#include "tpl_memmap.h"
%
end loop
end if
#------------------------------------------------------------------------------
# resources table.
# generate only if at least one resource exists
#
if [REGULARRESOURCES length] > 0 | OS::USERESSCHEDULER then
loop core_id from 0 to OS::NUMBER_OF_CORES - 1 do
if [REGULARRESOURCES length] > 0 | OS::USERESSCHEDULER then
%
#define OS_START_SEC_CONST_UNSPECIFIED
#include "tpl_memmap.h"
CONSTP2VAR(tpl_resource, AUTOMATIC, OS_APPL_DATA)
CONSTP2VAR(tpl_resource, AUTOMATIC, OS_APPL_DATA)%
if OS::NUMBER_OF_CORES > 1 then%
tpl_resource_table_core% !core_id %[RESOURCE_COUNT] = {%
else%
tpl_resource_table[RESOURCE_COUNT] = {%
foreach resource in REGULARRESOURCES
before %
end if
foreach resource in REGULARRESOURCES
before %
%
do
do
# Check if this core has this resource, add the resource descriptor if
# yes.
let accessing_application := false
foreach application in APPLICATIONS do
if exists application::CORE default(0) == core_id then
let res_map := mapof exists application::RESOURCE default(emptylist) by VALUE
let app_map := mapof exists resource::ACCESSING_APPLICATION default(emptylist) by VALUE
if (exists res_map[resource::NAME])
| (exists app_map[application::NAME]) then
let accessing_application := true
end if
end if
end foreach
if accessing_application then
%&% !resource::NAME %_rez_desc%
between
else
%NULL%
end if
between
%,
%
end foreach
%
end foreach
if OS::USERESSCHEDULER then
if [REGULARRESOURCES length] > 0 then %,% end if
%
if OS::USERESSCHEDULER then
if [REGULARRESOURCES length] > 0 then %,% end if
if OS::NUMBER_OF_CORES > 1 then%
&res_sched_core% !core_id %_rez_desc%
else %
&res_sched_rez_desc%
end if
%
end if
end if
%
};
#define OS_STOP_SEC_CONST_UNSPECIFIED
#include "tpl_memmap.h"
%
end if
end loop
if OS::NUMBER_OF_CORES > 1 then%
#define OS_START_SEC_CONST_UNSPECIFIED
#include "tpl_memmap.h"
CONSTP2CONST(tpl_resource*, AUTOMATIC, OS_CONST)
tpl_resource_table[NUMBER_OF_CORES] = {
%
loop core_id from 0 to OS::NUMBER_OF_CORES - 1 do
% tpl_resource_table_core% !core_id
between %,
%
end loop
%
};
#define OS_STOP_SEC_CONST_UNSPECIFIED
#include "tpl_memmap.h"
%
end if
#------------------------------------------------------------------------------
foreach resource in INTERNALRESOURCES
@@ -70,28 +70,6 @@ CONST(tpl_resource_id, AUTOMATIC) INVALID_RESOURCE = (tpl_resource_id)(-1);
#define OS_STOP_SEC_CONST_UNSPECIFIED
#include "tpl_memmap.h"
#define OS_START_SEC_VAR_UNSPECIFIED
#include "tpl_memmap.h"
/**
* The scheduler resource descriptor
*
* @see #RES_SCHEDULER
*/
VAR(tpl_resource, OS_VAR) res_sched_rez_desc = {
RES_SCHEDULER_PRIORITY, /* ceiling priority */
0, /* owner_prev_priority */
INVALID_PROC_ID, /* owner */
#if WITH_OSAPPLICATION == YES
INVALID_OSAPPLICATION_ID, /* OS Application id */
#endif
NULL /* next_res */
};
#define OS_STOP_SEC_VAR_UNSPECIFIED
#include "tpl_memmap.h"
#define OS_START_SEC_CODE
#include "tpl_memmap.h"
@@ -110,6 +88,7 @@ FUNC(void, OS_CODE) tpl_release_all_resources(
P2VAR(tpl_resource, AUTOMATIC, OS_APPL_DATA) res =
tpl_dyn_proc_table[proc_id]->resources;
#if WITH_TRACE == YES
GET_CURRENT_CORE_ID(core_id)
VAR(tpl_resource_id, AUTOMATIC) res_id;
#endif /* WITH_TRACE */
@@ -127,7 +106,7 @@ FUNC(void, OS_CODE) tpl_release_all_resources(
/* find the id of the resource for the trace */
#if WITH_TRACE == YES
res_id = 0;
while( tpl_resource_table[res_id] != res ){
while( TPL_RESOURCE_TABLE(core_id)[res_id] != res ){
res_id++;
}
TRACE_RES_RELEASED(res_id)
@@ -173,7 +152,7 @@ FUNC(tpl_status, OS_CODE) tpl_get_resource_service(
IF_NO_EXTENDED_ERROR(result)
#if RESOURCE_COUNT > 0
res = tpl_resource_table[res_id];
res = TPL_RESOURCE_TABLE(core_id)[res_id];
#else
res = NULL; /* error */
#endif
@@ -256,7 +235,7 @@ FUNC(tpl_status, OS_CODE) tpl_release_resource_service(
IF_NO_EXTENDED_ERROR(result)
#if RESOURCE_COUNT > 0
res = tpl_resource_table[res_id];
res = TPL_RESOURCE_TABLE(core_id)[res_id];
#else
res = NULL; /* error */
#endif
@@ -71,21 +71,28 @@ struct TPL_RESOURCE {
typedef struct TPL_RESOURCE tpl_resource;
#if RESOURCE_COUNT > 0
# if NUMBER_OF_CORES == 1
/**
* Array of all resources descriptors
*
* Index in this array correspond to the #ResourceType of the resource
*/
extern CONSTP2VAR(tpl_resource, AUTOMATIC, OS_APPL_DATA)
tpl_resource_table[RESOURCE_COUNT];
#endif /* RESOURCE_COUNT */
# define TPL_RESOURCE_TABLE(a_core_id) tpl_resource_table
# else
/**
* The scheduler resource descriptor
* Array of all resources descriptors
*
* @see #RES_SCHEDULER
* In multicore, tpl_ressource_table is an array indexed by a core id
* containing the addresses of the core's tpl_ressource_table.
*/
extern VAR(tpl_resource, OS_VAR) res_sched_rez_desc;
extern CONSTP2CONST(tpl_resource*, AUTOMATIC, OS_CONST)
tpl_resource_table[NUMBER_OF_CORES];
# define TPL_RESOURCE_TABLE(a_core_id) (tpl_resource_table[a_core_id])
# endif
#endif /* RESOURCE_COUNT */
#define OS_START_SEC_CODE
#include "tpl_memmap.h"

0 comments on commit a28625f

Please sign in to comment.