Skip to content
Snippets Groups Projects
Commit f0f18ddd authored by Federico's avatar Federico
Browse files

Encapsulate thread pointer in flags

parent 645e8bb1
Branches
No related tags found
2 merge requests!40Update to Miosix 2.7,!17Draft: Improved miosix build system and fixed cmake scripts
...@@ -717,7 +717,7 @@ void Thread::setupUserspaceContext(unsigned int entry, unsigned int *gotBase, ...@@ -717,7 +717,7 @@ void Thread::setupUserspaceContext(unsigned int entry, unsigned int *gotBase,
#endif //WITH_PROCESSES #endif //WITH_PROCESSES
Thread::Thread(unsigned int *watermark, unsigned int stacksize, Thread::Thread(unsigned int *watermark, unsigned int stacksize,
bool defaultReent) : schedData(), flags(), savedPriority(0), bool defaultReent) : schedData(), flags(this), savedPriority(0),
mutexLocked(nullptr), mutexWaiting(nullptr), watermark(watermark), mutexLocked(nullptr), mutexWaiting(nullptr), watermark(watermark),
ctxsave(), stacksize(stacksize) ctxsave(), stacksize(stacksize)
{ {
...@@ -782,7 +782,6 @@ Thread *Thread::doCreate(void*(*startfunc)(void*) , unsigned int stacksize, ...@@ -782,7 +782,6 @@ Thread *Thread::doCreate(void*(*startfunc)(void*) , unsigned int stacksize,
reinterpret_cast<unsigned int*>(thread),argv); reinterpret_cast<unsigned int*>(thread),argv);
if((options & JOINABLE)==0) thread->flags.IRQsetDetached(); if((options & JOINABLE)==0) thread->flags.IRQsetDetached();
thread->flags.t = thread;
return thread; return thread;
} }
......
...@@ -926,7 +926,7 @@ private: ...@@ -926,7 +926,7 @@ private:
/** /**
* Constructor, sets flags to default. * Constructor, sets flags to default.
*/ */
ThreadFlags() : flags(0) {} ThreadFlags(Thread *t) : t(t), flags(0) {}
/** /**
* Set the wait flag of the thread. * Set the wait flag of the thread.
...@@ -1034,7 +1034,9 @@ private: ...@@ -1034,7 +1034,9 @@ private:
*/ */
bool isInUserspace() const { return flags & USERSPACE; } bool isInUserspace() const { return flags & USERSPACE; }
Thread* t; //Unwanted methods
ThreadFlags(const ThreadFlags& p) = delete;
ThreadFlags& operator = (const ThreadFlags& p) = delete;
private: private:
///\internal Thread is in the wait status. A call to wakeup will change ///\internal Thread is in the wait status. A call to wakeup will change
...@@ -1061,6 +1063,7 @@ private: ...@@ -1061,6 +1063,7 @@ private:
///\internal Thread is running in userspace ///\internal Thread is running in userspace
static const unsigned int USERSPACE=1<<6; static const unsigned int USERSPACE=1<<6;
Thread* t; ///<\internal pointer to the thread to which the flags belong
unsigned char flags;///<\internal flags are stored here unsigned char flags;///<\internal flags are stored here
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment