#ifndef __MUTEX_H__
#define __MUTEX_H__

#include "rtos_defs.h"
#include "target.h"

class Mutex
{
	public:
		inline Mutex() : _processMap(0), _valueTag(0) { }
		void Lock();
		void Unlock();
		void UnlockISR();

		inline bool LockSoftly()     { CriticalSection cs; if (_valueTag) return false; else Lock(); return true; }
		inline bool IsLocked() const { CriticalSection cs; if (_valueTag) return true; else return false; }

	private:
		ProcessMap _processMap;
		ProcessMap _valueTag;
};


#endif // __MUTEX_H__
