one area that we allocate. The areaManager should really be created when the process is created, so this is something to wait for HW integration time. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@983 a95241bf-73f2-0310-859d-f6bbb57e9c96
39 lines
965 B
C++
39 lines
965 B
C++
#include "areaPool.h"
|
|
#include "area.h"
|
|
#include "page.h"
|
|
#include "vmHeaderBlock.h"
|
|
#include "pageManager.h"
|
|
|
|
extern vmHeaderBlock *vmBlock;
|
|
|
|
area *poolarea::get(void)
|
|
{
|
|
area *ret=NULL;
|
|
if (unused.count())
|
|
{
|
|
//printf ("poolarea::get: Getting an unused one!\n");
|
|
acquire_sem(inUse);
|
|
ret=(area *)unused.next();
|
|
release_sem(inUse);
|
|
}
|
|
if (ret)
|
|
{
|
|
//printf ("poolarea::get: Returning address:%x \n",ret);
|
|
return ret;
|
|
}
|
|
else
|
|
{
|
|
//printf ("poolarea::get: Getting a new page!\n");
|
|
page *newPage=vmBlock->pageMan->getPage();
|
|
if (!newPage)
|
|
throw ("Out of pages to allocate a pool!");
|
|
int newCount=PAGE_SIZE/sizeof(area);
|
|
acquire_sem(inUse);
|
|
//printf ("poolarea::get: Adding %d new elements to the pool!\n",newCount);
|
|
for (int i=0;i<newCount;i++)
|
|
unused.add(((void *)(newPage->getAddress()+(i*sizeof(area)))));
|
|
release_sem(inUse);
|
|
return (get()); // A little cheat - call self again to get the first one from stack...
|
|
}
|
|
}
|