TD2 II.3-4 Manage UserStack with Bitmap

Add a Semaphore to manage threads waiting list
This commit is contained in:
Yorick Barbanneau 2021-11-18 23:12:42 +01:00
parent 6e0d91918a
commit 4da093ca38
4 changed files with 67 additions and 11 deletions

View file

@ -19,6 +19,13 @@
#include "noff.h"
#include "list.h"
#ifdef CHANGED
#include "bitmap.h"
class Semaphore;
#define UserStackSize 256
#endif //CHANGED
#define UserStacksAreaSize 1024 // increase this as necessary!
class AddrSpace:public dontcopythis
@ -41,8 +48,12 @@ class AddrSpace:public dontcopythis
// Dump program layout as SVG
unsigned NumPages() { return numPages; }
#ifdef CHANGED
int Threads; // count number of threads into address space
int threads; // count number of threads into address space
Semaphore * semThreadsCounter;
Semaphore * semAllocateUserStack;
BitMap * memoryMap;
int AllocateUserStack();
void DeAllocateUserStack(int addr);
#endif
private:
NoffHeader noffH; // Program layout