EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Error "ObjectTableIsFull" while CreateProtectedTask()

Started by Alex Vinokur February 27, 2006
=============
INTEGRITY RTOS
=============

Here is fragment of a program that produces error.

Two task are to be created, both are using the same entry point
function.

The second task is not created.

Is there something wrong in this program?


====== Fragments of program ======

void CheckError(Error error)
{
    if (error == Success) return;

    cerr << IntegrityError = " << error << " : " << ErrorString (error)
<< endl;
    HaltTask(CurrentTask());
}



Task task[2];

for (size_t i = 0; i < 2; i++)
{
  char taskName[25];
  sprintf (taskName, "task-%d", i);

  CheckError (CreateProtectedTask(1, (Address)func, 0x7000, taskName,
&task[i]));
  cerr << taskName << ": CreateProtectedTask() performed" << endl;

  CheckError (SetTaskIdentification(interfaceTask[i],
(Address)&taskData[i]));
  cerr << taskName << ": SetTaskIdentification() performed" << endl;

  CheckError (RunTask(interfaceTask[i]));
  cerr << taskName << ": RunTask() performed" << endl;
}

==================================


====== Output ======

task-0: CreateProtectedTask() performed
task-0: SetTaskIdentification() performed
task-0: RunTask() performed
IntegrityError = 3 : ObjectTableIsFull

====================


Error "ObjectTableIsFull" for CreateProtectedTask means
"The caller cannot create the required Object Table Entries for
allocating the stack segment"


---
 Alex Vinokur
     email: alex DOT vinokur AT gmail DOT com
     http://mathforum.org/library/view/10978.html
     http://sourceforge.net/users/alexvn

Here is a new experiment.

A program below
* works fine with STACK_SIZE=0x2000
* produces Error-44 (NoPagesOnFreeList)
* produces Error-3  (ObjectTableIsFull)


How should we manage memory resources in order to get programs working
fine?


------ foo.cc ------

#include <INTEGRITY.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <util/error_string.h>
using namespace std;

#define STACK_SIZE 0x2000	// OK
// #define STACK_SIZE 0x5000	// IntegrityError = 44: NoPagesOnFreeList
// #define STACK_SIZE 0x7000	// IntegrityError = 3: ObjectTableIsFull

static Semaphore sem;

struct Data
{
    char*    m_pValue;
    int      m_iValue;
    Data(char * i_pValue = 0, int i_iValue = 0)
	:
	m_pValue (i_pValue),
	m_iValue (i_iValue)
    {}
};

void CheckError(Error i_Error)
{
    if (i_Error == Success) return;

    cerr << "IntegrityError = " << i_Error << ": " <<
ErrorString(i_Error) << endl;

    HaltTask(CurrentTask());
}

void task(void)
{
    ReleaseSemaphore(sem);
    Exit(0);
}

#define NUMBER_OF_TASKS 3
int main(void)
{
    Task children[NUMBER_OF_TASKS];

    char taskName[NUMBER_OF_TASKS][25];
    for (size_t i = 0; i < NUMBER_OF_TASKS; i++)
    {
	sprintf (taskName[i], "child-%d", i);
    }

    CheckError (CreateSemaphore(0, &sem));
    cerr << "CreateSemaphore() performed" << endl;
    // --- Spawn the children ---
    vector<Data> taskData (NUMBER_OF_TASKS);
    for (size_t i = 0; i < NUMBER_OF_TASKS; i++)
    {
	CheckError (CreateProtectedTask(1, (Address)task, STACK_SIZE,
taskName[i], &children[i]));
	cerr << taskName[i] << ": CreateProtectedTask() performed" << endl;

	CheckError (SetTaskIdentification(children[i],
(Address)&taskData[i]));
	cerr << taskName[i] << ": SetTaskIdentification() performed" << endl;

	CheckError (RunTask(children[i]));
	cerr << taskName[i] << ": RunTask() performed" << endl;
    }

    // ------------------------
    for (size_t i = 0; i < NUMBER_OF_TASKS; i++)
    {
	CheckError (WaitForSemaphore(sem));
	cerr << taskName[i] << ": WaitForSemaphore() performed" << endl;
    }

    // ------------------------
    for (size_t i = 0; i < NUMBER_OF_TASKS; i++)
    {
	CheckError (CloseProtectedTask(children[i]));
	cerr << taskName[i] << ": CloseProtectedTask() performed" << endl;
    }

    exit (0);
}

--------------------


--- Output for STACK_SIZE=0x2000 ---

CreateSemaphore() performed
child-0: CreateProtectedTask() performed
child-0: SetTaskIdentification() performed
child-0: RunTask() performed
child-1: CreateProtectedTask() performed
child-1: SetTaskIdentification() performed
child-1: RunTask() performed
child-2: CreateProtectedTask() performed
child-2: SetTaskIdentification() performed
child-2: RunTask() performed
child-0: WaitForSemaphore() performed
child-1: WaitForSemaphore() performed
child-2: WaitForSemaphore() performed
child-0: CloseProtectedTask() performed
child-1: CloseProtectedTask() performed
child-2: CloseProtectedTask() performed

------------------------------------


--- Output for STACK_SIZE=0x5000 ---

CreateSemaphore() performed
child-0: CreateProtectedTask() performed
child-0: SetTaskIdentification() performed
child-0: RunTask() performed
child-1: CreateProtectedTask() performed
child-1: SetTaskIdentification() performed
child-1: RunTask() performed
IntegrityError = 44: NoPagesOnFreeList

------------------------------------


--- Output for STACK_SIZE=0x7000 ---

CreateSemaphore() performed
child-0: CreateProtectedTask() performed
child-0: SetTaskIdentification() performed
child-0: RunTask() performed
IntegrityError = 3: ObjectTableIsFull

------------------------------------


---
 Alex Vinokur
     email: alex DOT vinokur AT gmail DOT com
     http://mathforum.org/library/view/10978.html
     http://sourceforge.net/users/alexvn

Alex Vinokur wrote:

[snip]

> A program below > * works fine with STACK_SIZE=0x2000 > * produces Error-44 (NoPagesOnFreeList) > * produces Error-3 (ObjectTableIsFull) > > > How should we manage memory resources in order to get programs working > fine? >
A stack of size StackSize while CreateProtectedTask() is allocated from the AddressSpace's default MemoryRegionPool.
> > ------ foo.cc ------ > > #include <INTEGRITY.h> > #include <stdio.h> > #include <iostream> > #include <vector> > #include <util/error_string.h> > using namespace std; >
// ------ With default MemoryRegionPool ------
> #define STACK_SIZE 0x2000 // OK > // #define STACK_SIZE 0x5000 // IntegrityError = 44: NoPagesOnFreeList > // #define STACK_SIZE 0x7000 // IntegrityError = 3: ObjectTableIsFull
// ------------------------------------------- // ------ MemoryPoolSize = 0x200000 ------ // MemoryPoolSize 0x200000 has been set in Integrate file (foo.int) #define STACK_SIZE 0x7000 // Works OK // --------------------------------------- [snip]
> for (size_t i = 0; i < NUMBER_OF_TASKS; i++) > { > CheckError (CreateProtectedTask(1, (Address)task, STACK_SIZE, > taskName[i], &children[i]));
[snip
> }
[snip] Nevertheless, there is some question. CreateProtectedTask() returns Success or ErrorCode. Two of ErrorCode's are as follows: 1) ResourceNotAvailable: There is not a region of the desired size in the MemoryRegionPool. 2) MemoryPoolExhausted: There is not sufficient AddressSpace heap memory available for temporary storage and MemoryRegionPool accounting data. It seems that CreateProtectedTask() should return one of those ErrorCode's in case if StackSize passed to CreateProtectedTask() and MemoryPoolSize are inconsistent.(?) --- Alex Vinokur email: alex DOT vinokur AT gmail DOT com http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn

The 2024 Embedded Online Conference