INOS
inos_syn.h
Go to the documentation of this file.
1//******************************************************************************
27//******************************************************************************
28
29#if !defined( __INOS_SYN_H )
30#define __INOS_SYN_H
31
32//--------------------------------------------------------------------------
33//--- includes -----------------------------------------------------------------
34//------------------------------------------------------------------------------
35
36//------------------------------------------------------------------------------
37//--- definitions --------------------------------------------------------------
38//------------------------------------------------------------------------------
39
40#define INOS_NO_WAIT 0x00000000 // don't wait
41#define INOS_WAIT_FOREVER 0xFFFFFFFF // wait forever
42
43// --- locking cache -----------------------------------------------------------
44
45#ifndef ICACHE
46#ifdef INOS_CACHE_LOCK_SUPPORT
47#define ICACHE __attribute__ ((section (".icache")))
48#define DCACHE __attribute__ ((section (".dcache")))
49#else
50#define ICACHE
51#define DCACHE
52#endif
53#endif
54
55//------------------------------------------------------------------------------
56//--- forwards -----------------------------------------------------------------
57//------------------------------------------------------------------------------
58class CINOSSyncNode;
59class CINOSTaskExMsg;
60class CINOSBus;
61
62//------------------------------------------------------------------------------
63//--- class CINOSSync ----------------------------------------------------------
64//------------------------------------------------------------------------------
65
67{
68 //--- user interface ---------------------------------------------------
69
70 // constructor / destructor
71 public :
81 const char* aName=0,
82 uint32 aInitialCount=0,
83 bool aManual=false
84 );
85
88 virtual ~CINOSSync();
89
90 // public member functions
91 public :
94 virtual const char* GetName() { return m_pName;};
95
102 ICACHE virtual uint32 Wait(uint32 aTimeout=INOS_WAIT_FOREVER);
103
106 ICACHE virtual void Signal() { iSignal(false); }
107
115 ICACHE virtual void SignalEx(CINOSTaskExMsg* apMsg, uint32 auRplId, uint32 auAppError) { Signal(); };
116
121 ICACHE virtual bool MsgEvent(CINOSTaskExMsg* apMsg) { return false; };
122
123
126 virtual void Reset();
127
130 volatile uint32* GetLockAdr()
131 { return m_Lock.GetAddr(); };
132
133 // returns true if the event relies on polling to detect state transition.
134 // this is necessary for 'raw' handled ports.
135 virtual bool UsesPolling() const {return false;};
136
137 bool IsSame(CINOSSync* i_pSync) {
138 return this == i_pSync;
139 }
140
141 #if defined(INOS_SYNCGUARD)
143 // remember that we're referenced
145 // return the address of the object
146 return this;
147 }
148 #endif
149
150 //--- internals --------------------------------------------------------
151
152 friend class CINOSKernel;
153 friend class CINOSScheduler;
154 friend class CINOSTask;
155 friend class CINOSMultiSync;
156
157 // protected members
158 protected:
159 const char* m_pName;
160 uint32 m_uCount;
165 CINOSSyncNode* m_pNode;
166 #if defined(INOS_SYNCGUARD)
167 uint32 m_uReferenced{};
168 uint32 m_uReferencedByParent{};
169 #endif
170
171 // operators
172 public:
173 int operator < (const CINOSSync& aSync) const
174 { return (strcmp(m_pName, aSync.m_pName)<0);}
175 int operator == (const CINOSSync& aSync) const
176 { return (strcmp(m_pName, aSync.m_pName)==0);}
177 int operator < (const char* aName) const
178 { return (strcmp(m_pName, aName)<0);}
179 int operator == (const char* aName) const
180 { return (strcmp(m_pName, aName)==0);}
181
182 // protected member functions
183 protected :
184 // parent checks signaled state
185 ICACHE virtual bool Signaled(CINOSSync*& aChild);
186 // get pointer to object node
187 /*ICACHE*/ virtual CINOSSyncNode* GetNode() {return m_pNode;};
188 // set pointer to object node
189 /*ICACHE*/ virtual void SetNode(CINOSSyncNode* aNode) {m_pNode = aNode;};
190
196 ICACHE void SignalAndUnlock(uint32 auMsr) {
197 iSignal(true, auMsr);
198 }
199
200 // private member functions
201 private :
207 void iSignal(bool abAlreadyLocked, uint32 uMsr = 0);
208
209 // allow dynamic object handling (new/delete)
211};
212
213//------------------------------------------------------------------------------
214//--- class CINOSMultiSync -----------------------------------------------------
215//------------------------------------------------------------------------------
216
235{
236 //--- user interface ---------------------------------------------------
237
238 // constructor / destructor
239 public :
240 CINOSMultiSync(const char* aName=0);
241 virtual ~CINOSMultiSync();
242
243 // public member functions
244 public :
254 void Remove(CINOSSync* aChild, bool aDelete=false);
258 void RemoveAll(bool aDelete=false);
259
262 ICACHE virtual uint32 Wait(uint32 aTimeout=INOS_WAIT_FOREVER);
266 ICACHE virtual uint32 Wait(CINOSSync*& aChild, uint32 aTimeout=INOS_WAIT_FOREVER);
267
270 virtual void Reset();
271
272 // returns true if the event relies on polling to detect state transition.
273 // this is necessary for 'raw' handled ports.
274 virtual bool UsesPolling() const {return m_bUsesPolling;};
275
279 CINOSBus* GetBus() { return m_pBus; }
280 void SetBus(CINOSBus* apBus) { m_pBus = apBus; }
281
282 //--- internals --------------------------------------------------------
283
284 friend class CINOSSyncNode;
285
286 // protected members
287 protected:
288 CINOSSyncNode* pFirstChild; // pointer to first child
289 CINOSSyncNode* pLastChild; // pointer to last child
290
291 // exception handling
292 CINOSExceptionCleanup* pCleanup;
293
294 // Flag indicating if bit event is detected using polling
295 bool m_bUsesPolling;
296
297 // pointer to bus (if any) used for sleep
298 CINOSBus* m_pBus;
299
300 // protected member functions
301 protected :
302 // parent checks signaled state
303 ICACHE virtual bool Signaled(CINOSSync*& aChild);
304 // wake up because child state changed
305 void WakeUp();
306 // cleanup
307 void Cleanup();
308
309 // allow dynamic object handling (new/delete)
311};
312
313//------------------------------------------------------------------------------
314//--- class CINOSSyncNode ------------------------------------------------------
315//------------------------------------------------------------------------------
316
318class CINOSSyncNode
319{
320 friend class CINOSSync;
321 friend class CINOSMultiSync;
322 friend class CINOSBitSetEvent;
323 friend class CINOSBitClearedEvent;
324
325 // protected members
326 protected:
327 CINOSSync* pChild; // pointer to sync object
328 CINOSMultiSync* pParent; // pointer to parent sync object
329 CINOSSyncNode* pNext; // pointer to next node on the same level
330 // for the sake of simplicity (and runtime overhead), on multicore
331 // system, we do not support 'groups' of sync nodes anymore.
332 #ifndef INOS_MULTICORE
333 CINOSSyncNode* pNextGroup; // pointer to next sync group
334 #endif
335 bool mOrNode; // 'or' node true/false
336
337 // constructor / destructor
338 public :
339 CINOSSyncNode(CINOSMultiSync* aParent, CINOSSync* aChild, bool aOrNode);
340 ~CINOSSyncNode();
341
342 // protected member functions
343 protected :
344 // child changed to signaled state -> wake up parents
345 ICACHE void WakeUp();
346
347 // allow dynamic object handling (new/delete)
348 DECLARE_DYNAMIC(CINOSSyncNode);
349};
351
352
353//------------------------------------------------------------------------------
354//--- class CINOSConditionVariable ---------------------------------------------
355//------------------------------------------------------------------------------
356#include <mutex>
368{
369 public :
370 enum EStatus {
371 eNoTimeout,
372 eTimeout
373 };
374
379 CINOSConditionVariable(const char* aName=nullptr);
380
384
385 public :
388 template< class Rep, class Period >
389 EStatus WaitFor(std::unique_lock<CINOSMutex>& lock,
390 const std::chrono::duration<Rep, Period>& rel_time)
391 {
392 uint32 waitUs = std::chrono::duration_cast<std::chrono::microseconds>(rel_time).count();
393 const uint32 uWaitTime = DoWait(lock, waitUs);
394 return (uWaitTime == 0) ? eTimeout : eNoTimeout;
395 }
396
399 template< class Rep, class Period, class Predicate >
400 bool WaitFor( std::unique_lock<CINOSMutex>& lock,
401 const std::chrono::duration<Rep, Period>& rel_time,
402 Predicate pred) {
403 uint32 waitUs = checked_static_cast<uint32>(std::chrono::duration_cast<std::chrono::microseconds>(rel_time).count());
404 while( !pred() ) {
405 uint32 uWaitTime = DoWait(lock, waitUs);
406 if( !uWaitTime ) {
407 // timeout occurred
408 return false;
409 }
410 waitUs = (waitUs - uWaitTime) > 0 ? waitUs - uWaitTime : 0;
411 }
412 return true;
413 }
414
417 void Wait( std::unique_lock<CINOSMutex>& lock ) {
418 DoWait(lock);
419 }
420
423 template< class Predicate >
424 void wait( std::unique_lock<CINOSMutex>& lock, Predicate pred ) {
425 while( !pred() ) {
426 DoWait(lock);
427 }
428 }
429
432 void NotifyOne();
435 void NotifyAll();
436
437 private:
440 uint32 DoWait(std::unique_lock<CINOSMutex>& lock, uint32 auTimeout = INOS_WAIT_FOREVER);
441
442 // allow dynamic object handling (new/delete)
444 // objects of CINOSConditionVariable need to be created very early during startup, when
445 // the CTORs have not been executed. Therefore, in order to create such
446 // objects, we need to provide the placement operator new.
448
449};
450
451//------------------------------------------------------------------------------
452//--- class CINOSSemaphore -----------------------------------------------------
453//------------------------------------------------------------------------------
454
456{
457 //--- user interface ---------------------------------------------------
458
459 // public members
460 public :
467 const char* apName = 0,
469 uint32 auMaxCount = 0xffffffff
470 );
471
475
482 ICACHE uint32 Request(uint32 aTimeout=INOS_WAIT_FOREVER);
483
486 ICACHE void Release();
487
491 { return m_uCount; }
492
496 { return m_uMaxCount; }
497
498 //--- internals --------------------------------------------------------
499
500 private:
502 uint32 m_uMaxCount;
503
504 // allow dynamic object handling (new/delete)
506};
507
508//------------------------------------------------------------------------------
509//--- class CINOSQueue ---------------------------------------------------------
510//------------------------------------------------------------------------------
511
512class CINOSQueue : public CINOSSync
513{
514 //--- user interface ---------------------------------------------------
515
516 // public members
517 public :
523 // create a queue with 'aNumber' entries of 'aSize' bytes
524 CINOSQueue(const char* apName, uint32 auNumber, uint32 auSize);
525
528 virtual ~CINOSQueue();
529
538 ICACHE uint32 Put(void* aData, uint32 aTimeout=INOS_WAIT_FOREVER, uint32 auFlags=0);
539
547 ICACHE uint32 Get(void* aData, uint32 aTimeout=INOS_WAIT_FOREVER);
548
556 void Inquiry(void* aData, uint32& aCountOfElements);
557
568 bool InquiryAt(void* aData, uint32 auIndex);
569
572 void Flush();
573
577 bool Empty();
578
582 uint32 GetNumber();
583
587 const uint32 GetSize() const {
588 return mSize;
589 }
590
594 const uint32 GetMaxNumber() const {
595 return mMaxNumber;
596 }
597
601 const uint32* GetAdrNumber() const {
602 return &mNumber;
603 }
604
608 const uint64* GetAdrCount() const {
609 return &mCount;
610 }
611
615 void SetFlag(uint32 auFlag)
616 {
618 }
619
623 void ClrFlag(uint32 auFlag)
624 {
626 }
627
631 uint32 BeginAccess();
632
638 bool Access(void*&ptrData, uint32 auIndex);
639
643 void EndAccess(uint32 msr);
644
647 enum {
648 eFlgOverflowCheck = 0x00000001, // check queue overflows
649 eFlgOverflowFatal = 0x00000002, // fatal error in case of an overflow
650 eFlgAccess = 0x00000004, // data access active (queue locked)
651 eFlgUnique = 0x00000008, // only allow unique entries in queue
652 };
653
654 //--- internals --------------------------------------------------------
655
656 // protected members
657 protected :
658 void* pBegin;
659 void* pEnd;
660 void* pPut;
661 void* pGet;
662 uint32 mNumber;
663 uint32 mSize;
664 uint32 mMaxNumber;
665 uint32 mQueueFlags;
668
669 // allow dynamic object handling (new/delete)
671};
672
673// include task queue handling
674#include <cinostaskqueue.h>
675
676//------------------------------------------------------------------------------
677//--- class CINOSEvent ---------------------------------------------------------
678//------------------------------------------------------------------------------
679
680class CINOSEvent : public CINOSSync
681{
682 //--- user interface ---------------------------------------------------
683
684 // constructor / destructor
685 public :
687 const char* aName=0,
689 bool aManual=false
690 );
691 virtual ~CINOSEvent();
692
693 //--- internals --------------------------------------------------------
694
695 friend class CINOSBitSetEvent;
696 friend class CINOSBitClearedEvent;
697
698 // allow dynamic object handling (new/delete)
700};
701
702//------------------------------------------------------------------------------
703//--- class CINOSBitSetEvent ---------------------------------------------------
704//------------------------------------------------------------------------------
705
706#ifndef INOS_NO_BIT_EVENT_SUPPORT
707class CINOSBit;
709{
710 friend class CINOSBit;
711
712 //--- user interface ---------------------------------------------------
713
714 // constructor / destructor
715 public :
717 virtual ~CINOSBitSetEvent();
718
719 // public member functions
720 public :
721 // get name of sync object
722 virtual const char* GetName() {return m_pEvent->GetName();};
723 // wait for signaled state for max. aTimeout usec
724 virtual uint32 Wait(uint32 aTimeout=INOS_WAIT_FOREVER);
725 // put object into the signaled state
726 virtual void Signal();
727 // reset object state
728 virtual void Reset();
729 // returns true if the event relies on polling to detect state transition.
730 // this is necessary for 'raw' handled ports.
731 virtual bool UsesPolling() const {return m_bUsesPolling;};
732
733 //--- internals --------------------------------------------------------
734
735 // protected members
736 protected :
737 CINOSBit* m_pBit;
738 CINOSEvent* m_pEvent;
739
740 // exception handling
741 CINOSExceptionCleanup* m_pCleanup;
742
743 // Flag indicating if bit event is detected using polling
744 bool m_bUsesPolling;
745
746 // protected member functions
747 protected :
748 // parent checks signaled state
749 virtual bool Signaled(CINOSSync*& aChild);
750 // get pointer to object node
751 virtual CINOSSyncNode* GetNode(){return m_pEvent->GetNode();};
752 // set pointer to object node
753 virtual void SetNode(CINOSSyncNode* aNode){m_pEvent->SetNode(aNode);};
754 // cleanup
755 void Cleanup();
756
757 // allow dynamic object handling (new/delete)
759};
760
761//------------------------------------------------------------------------------
762//--- class CINOSBitClearedEvent -----------------------------------------------
763//------------------------------------------------------------------------------
764
766{
767 friend class CINOSBit;
768
769 //--- user interface ---------------------------------------------------
770
771 // constructor / destructor
772 public :
774 virtual ~CINOSBitClearedEvent();
775
776 // public member functions
777 public :
778 // get name of sync object
779 virtual const char* GetName() {return m_pEvent->GetName();};
780 // wait for signaled state for max. aTimeout usec
781 virtual uint32 Wait(uint32 aTimeout=INOS_WAIT_FOREVER);
782 // put object into the signaled state
783 virtual void Signal();
784 // reset object state
785 virtual void Reset();
786 // returns true if the event relies on polling to detect state transition.
787 // this is necessary for 'raw' handled ports.
788 virtual bool UsesPolling() const {return m_bUsesPolling;};
789
790 //--- internals --------------------------------------------------------
791
792 // protected members
793 protected :
794 CINOSBit* m_pBit;
795 CINOSEvent* m_pEvent;
796
797 // exception handling
798 CINOSExceptionCleanup* m_pCleanup;
799
800 // Flag indicating if bit event is detected using polling
801 bool m_bUsesPolling;
802
803 // protected member functions
804 protected :
805 // parent checks signaled state
806 virtual bool Signaled(CINOSSync*& aChild);
807 // get pointer to object node
808 virtual CINOSSyncNode* GetNode(){return m_pEvent->GetNode();};
809 // set pointer to object node
810 virtual void SetNode(CINOSSyncNode* aNode){m_pEvent->SetNode(aNode);};
811 // cleanup
812 void Cleanup();
813
814 // allow dynamic object handling (new/delete)
816};
817#endif
818
819//------------------------------------------------------------------------------
820//--- class CINOSTimeEvent -----------------------------------------------------
821//------------------------------------------------------------------------------
822
823#ifndef INOS_NO_1MS_SUPPORT
824class CINOSxmsHandler;
826{
827 //--- user interface ---------------------------------------------------
828
829 // constructor / destructor
830 public :
831 enum {
832 eEventDisabled = 0,
833 eUsePreviousTime = 0
834 };
835
841 virtual ~CINOSTimeEvent();
842
843 // public member functions
844 public :
845 // reset event with new time (time = 0 -> reset with old time)
846 void Reset(uint32 aTime=eUsePreviousTime);
851 void Stop();
852 // start event with new time (time = 0 -> reset with old time)
853 void Start(uint32 aTime=eUsePreviousTime);
854
855 //--- internals --------------------------------------------------------
856
857 private:
860 void iAddHandler();
861 void iRemoveHandler();
862
863 // protected members
864 protected :
865 uint32 mWaitTime = eEventDisabled;
866 CINOSxmsHandler* pHandler = nullptr;
867 // exception handling
868 CINOSExceptionCleanup* pCleanup = nullptr;
869
870 // protected member functions
871 protected :
872 // event handler
873 void Handler();
874 // cleanup
875 void Cleanup();
876
877 // allow dynamic object handling (new/delete)
879};
880
881#endif
882
883//--------------------------------------------------------------------------
884// CINOSSyncObjects
885//--------------------------------------------------------------------------
886
889{
890 //--- user interface ---------------------------------------------------
891
892 public :
893 // add sync object to the tree
894 void Add(CINOSSync* aSync);
895 // find sync object 'aName'
896 CINOSSync* Find(char* aName);
897
898 //--- internals --------------------------------------------------------
899
900 private :
901 // tree of all objects in the system
903
904 // constructor
905 public:
907};
909
910//--------------------------------------------------------------------------
911// CINOSLockGuard
912//--------------------------------------------------------------------------
913
914template<typename TLock>
916{
917 //--- user interface ---------------------------------------------------
918
919 public :
923 m_Lock(aLock), m_bLocked(false)
924 {
925 m_bLocked = (m_Lock.Request() != 0);
926 }
930 m_Lock(aLock), m_bLocked(false)
931 {
932 m_bLocked = (m_Lock.Request(auTimeout) != 0);
933 }
935 if (m_bLocked) m_Lock.Release();
936 }
937 bool IsLocked() const {
938 return m_bLocked;
939 }
940
941 //--- internals --------------------------------------------------------
942
943 private :
944 // Lock to be guarded
945 TLock& m_Lock;
946 // Flag indicating if the lock is held
947 bool m_bLocked;
948};
949
951
952//------------------------------------------------------------------------------
953//--- class CINOSRefCount ------------------------------------------------------
954//------------------------------------------------------------------------------
955
961{
962 //--- user interface ---------------------------------------------------
963
964 // public members
965 public :
972 const char* apParentName,
973 const char* apBaseName,
975 void* apHandlerObj = NULL,
976 void* apHandlerFunc = NULL
977 );
978
981 virtual ~CINOSRefCount();
982
986
990
994
998
999 //--- internals --------------------------------------------------------
1000
1001 protected :
1002
1005 friend class CINOSLockGuard<CINOSRefCount>;
1006 uint32 Request();
1007 void Release();
1008
1009 protected :
1011 inosName32 m_sName;
1016 void* m_pHandlerFunc;
1017
1018 // allow dynamic object handling (new/delete)
1020};
1021
1023
1025
1026//------------------------------------------------------------------------------
1027//--- class CINOSReadWriteLock -------------------------------------------------
1028//------------------------------------------------------------------------------
1033 public:
1037 void ReadLock() {
1038 std::unique_lock<CINOSMutex> lock(m_Mutex);
1039 while (HasForeignWriter()) {
1040 m_Unlocked.wait(lock, [this]() { return !HasForeignWriter(); });
1041 }
1042 m_uReaders++;
1043 }
1045 void ReadUnlock() {
1046 std::unique_lock<CINOSMutex> lock(m_Mutex);
1047 m_uReaders--;
1048 if (m_uReaders == 0)
1049 m_Unlocked.NotifyAll();
1050 }
1055 void WriteLock() {
1056 std::unique_lock<CINOSMutex> lock(m_Mutex);
1057 while (HasForeignWriter() || HasReaders()) {
1058 m_Unlocked.wait(lock, [this]() { return !(HasForeignWriter() || HasReaders()); });
1059 }
1060 ++m_nWriter;
1061 m_pWriter = ActualTask();
1062 }
1065 std::unique_lock<CINOSMutex> lock(m_Mutex);
1066 --m_nWriter;
1067 if (m_nWriter == 0) {
1068 m_pWriter = nullptr;
1069 m_Unlocked.NotifyAll();
1070 }
1071 }
1072 private:
1073 bool HasReaders() const {
1074 return m_uReaders > 0;
1075 }
1076 bool HasForeignWriter() const {
1077 const bool bHasWriter = m_nWriter > 0;
1078 const bool bWriterIsMe = ActualTask() == m_pWriter;
1079 return bHasWriter && !bWriterIsMe;
1080 }
1081 private:
1083 size_t m_uReaders{};
1086 size_t m_nWriter{0};
1088 CINOSTask* m_pWriter{nullptr};
1090 CINOSMutex m_Mutex;
1093 CINOSConditionVariable m_Unlocked;
1094};
1095//------------------------------------------------------------------------------
1096//--- class CINOSWriteLock -----------------------------------------------------
1097//------------------------------------------------------------------------------
1101 public:
1103 : m_Lock(aLock)
1104 {
1105 m_Lock.WriteLock();
1106 }
1107 ~CINOSWriteLock() {
1108 m_Lock.WriteUnlock();
1109 }
1110 CINOSReadWriteLock& m_Lock;
1111};
1112//------------------------------------------------------------------------------
1113//--- class CINOSReadLock ------------------------------------------------------
1114//------------------------------------------------------------------------------
1118 public:
1120 : m_Lock(aLock)
1121 {
1122 m_Lock.ReadLock();
1123 }
1124 ~CINOSReadLock() {
1125 m_Lock.ReadUnlock();
1126 }
1127 CINOSReadWriteLock& m_Lock;
1128};
1129
1130//--------------------------------------------------------------------------
1131// global variables
1132//--------------------------------------------------------------------------
1133
1134extern CINOSSyncObjects* pINOSSyncObjects; // binary tree of INOS sync objects
1135
1136#endif // __INOS_SYN_H
1137
#define DECLARE_DYNAMIC_PLACEMENT(aClass)
Definition cinospartitionmemory.h:348
#define DECLARE_DYNAMIC(aClass)
Definition cinospartitionmemory.h:328
Definition inos_syn.h:766
virtual const char * GetName()
Get name of sync object.
Definition inos_syn.h:779
virtual uint32 Wait(uint32 aTimeout=0xFFFFFFFF)
wait for signaled state for max. aTimeout usec
virtual void Signal()
Put object into the signaled state.
virtual void Reset()
Reset object state.
Definition inos_syn.h:709
virtual void Reset()
Reset object state.
virtual uint32 Wait(uint32 aTimeout=0xFFFFFFFF)
wait for signaled state for max. aTimeout usec
virtual void Signal()
Put object into the signaled state.
virtual const char * GetName()
Get name of sync object.
Definition inos_syn.h:722
Definition cinosbit.h:54
Definition cinosbus.h:600
Definition inos_syn.h:368
void NotifyAll()
Wake up all waiting tasks See http://en.cppreference.com/w/cpp/thread/condition_variable/notify_all f...
virtual ~CINOSConditionVariable()
Destroy condition variable object.
void Wait(std::unique_lock< CINOSMutex > &lock)
wait for being notified (even spuriously) See http://en.cppreference.com/w/cpp/thread/condition_varia...
Definition inos_syn.h:417
void wait(std::unique_lock< CINOSMutex > &lock, Predicate pred)
wait for being notified and 'pred' is true See http://en.cppreference.com/w/cpp/thread/condition_vari...
Definition inos_syn.h:424
bool WaitFor(std::unique_lock< CINOSMutex > &lock, const std::chrono::duration< Rep, Period > &rel_time, Predicate pred)
wait for being notified waiting at most aTimeout. See http://en.cppreference.com/w/cpp/thread/conditi...
Definition inos_syn.h:400
CINOSConditionVariable(const char *aName=nullptr)
void NotifyOne()
Wake up one waiting task See http://en.cppreference.com/w/cpp/thread/condition_variable/notify_one fo...
EStatus WaitFor(std::unique_lock< CINOSMutex > &lock, const std::chrono::duration< Rep, Period > &rel_time)
wait for being notified waiting at most aTimeout. See http://en.cppreference.com/w/cpp/thread/conditi...
Definition inos_syn.h:389
Definition inos_syn.h:681
Definition inoskernel.h:239
Definition inos_syn.h:916
CINOSLockGuard(TLock &aLock)
Definition inos_syn.h:922
CINOSLockGuard(TLock &aLock, uint32 auTimeout)
Definition inos_syn.h:929
Definition cinosmcmodule.h:1900
Definition inos_syn.h:235
virtual uint32 Wait(CINOSSync *&aChild, uint32 aTimeout=0xFFFFFFFF)
CINOSBus * GetBus()
Definition inos_syn.h:279
void Remove(CINOSSync *aChild, bool aDelete=false)
void And(CINOSSync *aChild)
virtual void Reset()
void Or(CINOSSync *aChild)
virtual uint32 Wait(uint32 aTimeout=0xFFFFFFFF)
void RemoveAll(bool aDelete=false)
Definition cinosmutex.h:36
Definition inos_syn.h:513
const uint32 * GetAdrNumber() const
Return address of entries counter.
Definition inos_syn.h:601
void * pGet
pointer to actual get block
Definition inos_syn.h:661
void ClrFlag(uint32 auFlag)
Clear queue flag(s)
Definition inos_syn.h:623
const uint32 GetSize() const
Return size of one queue entry.
Definition inos_syn.h:587
void * pPut
pointer to actual put block
Definition inos_syn.h:660
void EndAccess(uint32 msr)
EndAccess Needs to be called after Access.
void Flush()
Flush the queue.
const uint32 GetMaxNumber() const
Return maximum number of entries.
Definition inos_syn.h:594
bool Access(void *&ptrData, uint32 auIndex)
Access Try to gain access to the data at a given index. The call needs to be embraced by calls of uin...
void Inquiry(void *aData, uint32 &aCountOfElements)
Gets the first element without removing it from the queue. Moreover, aCountOfElements returns the num...
const uint64 * GetAdrCount() const
Return address of overall counter.
Definition inos_syn.h:608
CINOSSemaphore * pSemaphore
semaphore to handle the number of queue entries
Definition inos_syn.h:666
uint32 mSize
size of block in queue
Definition inos_syn.h:663
uint32 BeginAccess()
BeginAccess Needs to be called before Access.
bool InquiryAt(void *aData, uint32 auIndex)
Gets the element at auIndex (starting from 0..numberOfElementsInQueue) without removing it from the q...
uint32 Put(void *aData, uint32 aTimeout=0xFFFFFFFF, uint32 auFlags=0)
Put data to queue and wait for max. auTimeout usec if queue full.
void SetFlag(uint32 auFlag)
Set queue flag(s)
Definition inos_syn.h:615
uint32 GetNumber()
Get number of queue entries.
uint32 mMaxNumber
maximum number of blocks in queue
Definition inos_syn.h:664
uint32 Get(void *aData, uint32 aTimeout=0xFFFFFFFF)
Get data from queue and wait for max. auTimeout usec if queue empty.
uint32 mQueueFlags
queue flags
Definition inos_syn.h:665
void * pBegin
pointer to begin of queue buffer
Definition inos_syn.h:658
uint64 mCount
overall put count
Definition inos_syn.h:667
bool Empty()
Get queue state.
virtual ~CINOSQueue()
Destroy queue.
void * pEnd
pointer to end of queue buffer
Definition inos_syn.h:659
uint32 mNumber
actual number of blocks in queue
Definition inos_syn.h:662
CINOSQueue(const char *apName, uint32 auNumber, uint32 auSize)
Create a queue with the given name. See also Queue.
Definition inos_syn.h:1117
Definition inos_syn.h:1032
void ReadLock()
Definition inos_syn.h:1037
void WriteLock()
Definition inos_syn.h:1055
void ReadUnlock()
Definition inos_syn.h:1045
void WriteUnlock()
Definition inos_syn.h:1064
Definition inos_syn.h:961
int32 Increment()
Increment the reference counter and return the new value.
int32 GetCount()
Get current count.
void * m_pHandlerObj
Handler method to call when count reaches 0.
Definition inos_syn.h:1015
virtual ~CINOSRefCount()
Destroy reference counter.
void SetCount(int32 aiNewCount)
Set current count.
int32 Decrement()
Decrement the reference counter and return the new value.
inosName32 m_sName
Reference counter name (for debugging purposes)
Definition inos_syn.h:1011
CINOSRefCount(const char *apParentName, const char *apBaseName, int32 aiInitialCount=0, void *apHandlerObj=NULL, void *apHandlerFunc=NULL)
Create a reference counter with the given name.
int32 m_iCount
Reference count.
Definition inos_syn.h:1013
Definition inos_syn.h:456
virtual ~CINOSSemaphore()
Destroy semaphore.
void Release()
Release seamphore.
uint32 GetMaxCount()
Get max. allowed count.
Definition inos_syn.h:495
uint32 Request(uint32 aTimeout=0xFFFFFFFF)
Wait for semaphore for a max. amount of time.
CINOSSemaphore(const char *apName=0, uint32 auInitialCount=1, uint32 auMaxCount=0xffffffff)
Create a semaphore with the given name. See also Semaphore.
uint32 GetCount()
Get current count.
Definition inos_syn.h:490
Definition inos_syn.h:67
virtual ~CINOSSync()
Destroy sync object.
CINOSSync(const char *aName=0, uint32 aInitialCount=0, bool aManual=false)
virtual const char * GetName()
Get name of sync object.
Definition inos_syn.h:94
tTaskId m_idFstWaiting
id of first task waiting for the sync object
Definition inos_syn.h:162
virtual void SignalEx(CINOSTaskExMsg *apMsg, uint32 auRplId, uint32 auAppError)
Definition inos_syn.h:115
SINOSCoreLock m_Lock
core lock
Definition inos_syn.h:164
CINOSSyncNode * m_pNode
pointer to object node (if any)
Definition inos_syn.h:165
virtual bool MsgEvent(CINOSTaskExMsg *apMsg)
Definition inos_syn.h:121
const char * m_pName
name of sync object
Definition inos_syn.h:159
void SignalAndUnlock(uint32 auMsr)
Put object into the signaled state and release the core lock.
Definition inos_syn.h:196
virtual uint32 Wait(uint32 aTimeout=0xFFFFFFFF)
wait for signaled state for max. aTimeout usec
virtual void Signal()
Put object into the signaled state.
Definition inos_syn.h:106
tTaskId m_idLstWaiting
id of last task waiting for the sync object
Definition inos_syn.h:163
virtual void Reset()
Reset object state.
uint32 m_uCount
signaled count of object
Definition inos_syn.h:160
volatile uint32 * GetLockAdr()
Return pointer to core locking structure.
Definition inos_syn.h:130
bool m_bManual
manual object yes/no
Definition inos_syn.h:161
Definition cinostaskex.h:396
Definition cinostask.h:52
Definition inos_syn.h:826
CINOSTimeEvent(uint32 aTime)
Definition inos_syn.h:1100
Definition inos_1ms.h:143
CINOSTask * ActualTask()
Definition inostype.h:258
Definition inostype.h:192