Gervot Olivier(deleted)
01/06/2015 11:13 AM
post112837
|
Hi
I am curently testing the adaptative partitionning
I wrote the following test program. It does the following tasks
Try to create a partition
If already created lookup for id
Joint the partition
Consume CPU (while loop)
#include <sys/sched_aps.h> // sched_aps_partition_info
#include <sys/neutrino.h> // SchedCtl
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h> // usleep
int main(void) {
_Int16t id = 0;
// create a partition
sched_aps_create_parms creation_data;
memset(&creation_data, 0, sizeof(creation_data));
creation_data.budget_percent = 15;
creation_data.critical_budget_ms = 0;
creation_data.name = "DebugReserve";
// Ne peut etre appelle qu'une fois avec un nom donne
int ret = SchedCtl( SCHED_APS_CREATE_PARTITION, &creation_data, sizeof(creation_data));
if (ret != EOK)
{
printf("Couldn t create partition \"%s\": %s (%d).\n", creation_data.name, strerror(errno), errno);
// already created
sched_aps_lookup_parms lookup_data;
memset(&lookup_data , 0 , sizeof ( lookup_data ) ) ;
lookup_data.name = "DebugReserve";
int ret = SchedCtl(SCHED_APS_LOOKUP, &lookup_data, sizeof(lookup_data) );
if (EOK != ret)
{
printf("err SchedCtl SCHED_APS_LOOKUP ret %d errno %d %s\n",ret, errno, sys_errlist[errno]);
}
else
{
//use output field
printf("SchedCtl SCHED_APS_LOOKUP OK id %d\n", lookup_data.id);
id = lookup_data.id;
}
}
else
{
printf ("The new partition ID is %d.\n", creation_data.id);
id = creation_data.id;
}
sched_aps_join_parms join_data;
memset(&join_data, 0, sizeof(join_data));
join_data.id = id;
join_data.pid = 0;
join_data.tid = 0;
ret = SchedCtl( SCHED_APS_JOIN_PARTITION, &join_data, sizeof(join_data));
if (ret != EOK)
{
printf("Couldn’t join partition %d: %s (%d).\n",
join_data.id, strerror(errno), errno);
}
else
{
printf ("Process is now in partition %d.\n", join_data.id);
}
// Consume max CPU
while(1)
{
//usleep(1);
}
return 0;
}
I run both 3 instance of this program
if execute: aps show -v
the display is
+----------- CPU Time ------------+-- Critical Time --
| | Used | |
Partition name id | Budget | 0.100s 1.00s 10.0s | Budget | Used
--------------------+---------------------------------+-------------------
System 0 | 85% | 0.13% 0.07% 0.23% | 400ms | 0.000ms
DebugReserve 1 | 15% | 74.04% 73.37% 64.13% | 0ms | 0.000ms
--------------------+---------------------------------+-------------------
Total | 100% | 74.17% 73.44% 64.36% |
The budget for the "DebugReserve" partition is 15% but the program overrun the budget of 15%
what is the problem, the code or my reasoning ?
|
|
|