Multiple thread can block on an event.
This commit is contained in:
parent
8dbd64121f
commit
b0d0cdbd7d
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: vvm_pevent.cc,v 1.6 2000/04/10 05:26:07 steve Exp $"
|
#ident "$Id: vvm_pevent.cc,v 1.7 2000/04/12 01:53:07 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vvm.h"
|
# include "vvm.h"
|
||||||
|
|
@ -31,15 +31,21 @@ vvm_sync::vvm_sync()
|
||||||
|
|
||||||
void vvm_sync::wait(vvm_thread*thr)
|
void vvm_sync::wait(vvm_thread*thr)
|
||||||
{
|
{
|
||||||
assert(hold_ == 0);
|
assert(thr->sync_back_ == 0);
|
||||||
|
thr->sync_next_ = hold_;
|
||||||
|
thr->sync_back_ = this;
|
||||||
hold_ = thr;
|
hold_ = thr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vvm_sync::wakeup()
|
void vvm_sync::wakeup()
|
||||||
{
|
{
|
||||||
|
while (hold_) {
|
||||||
vvm_thread*tmp = hold_;
|
vvm_thread*tmp = hold_;
|
||||||
hold_ = 0;
|
hold_ = tmp->sync_next_;
|
||||||
if (tmp) tmp->thread_yield();
|
assert(tmp->sync_back_ == 0);
|
||||||
|
tmp->sync_back_ = 0;
|
||||||
|
tmp->thread_yield();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -130,6 +136,9 @@ void vvm_anyedge::take_value(unsigned key, vpip_bit_t val)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vvm_pevent.cc,v $
|
* $Log: vvm_pevent.cc,v $
|
||||||
|
* Revision 1.7 2000/04/12 01:53:07 steve
|
||||||
|
* Multiple thread can block on an event.
|
||||||
|
*
|
||||||
* Revision 1.6 2000/04/10 05:26:07 steve
|
* Revision 1.6 2000/04/10 05:26:07 steve
|
||||||
* All events now use the NetEvent class.
|
* All events now use the NetEvent class.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: vvm_thread.cc,v 1.4 2000/02/23 02:56:57 steve Exp $"
|
#ident "$Id: vvm_thread.cc,v 1.5 2000/04/12 01:53:07 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vvm.h"
|
# include "vvm.h"
|
||||||
|
|
@ -39,6 +39,8 @@ class delay_event : public vvm_event {
|
||||||
|
|
||||||
vvm_thread::vvm_thread()
|
vvm_thread::vvm_thread()
|
||||||
{
|
{
|
||||||
|
sync_next_ = 0;
|
||||||
|
sync_back_ = 0;
|
||||||
thread_yield();
|
thread_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,6 +56,9 @@ void vvm_thread::thread_yield(unsigned long delay)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vvm_thread.cc,v $
|
* $Log: vvm_thread.cc,v $
|
||||||
|
* Revision 1.5 2000/04/12 01:53:07 steve
|
||||||
|
* Multiple thread can block on an event.
|
||||||
|
*
|
||||||
* Revision 1.4 2000/02/23 02:56:57 steve
|
* Revision 1.4 2000/02/23 02:56:57 steve
|
||||||
* Macintosh compilers do not support ident.
|
* Macintosh compilers do not support ident.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: vvm_thread.h,v 1.5 2000/02/23 02:56:57 steve Exp $"
|
#ident "$Id: vvm_thread.h,v 1.6 2000/04/12 01:53:07 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vvm.h"
|
# include "vvm.h"
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
* future.
|
* future.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class vvm_sync;
|
||||||
class vvm_thread {
|
class vvm_thread {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -46,10 +47,16 @@ class vvm_thread {
|
||||||
// will return false if it is ready to give up the CPU.
|
// will return false if it is ready to give up the CPU.
|
||||||
virtual bool go() =0;
|
virtual bool go() =0;
|
||||||
|
|
||||||
|
// The sync class uses this to list all the threads blocked on it.
|
||||||
|
vvm_sync*sync_back_;
|
||||||
|
vvm_thread*sync_next_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vvm_thread.h,v $
|
* $Log: vvm_thread.h,v $
|
||||||
|
* Revision 1.6 2000/04/12 01:53:07 steve
|
||||||
|
* Multiple thread can block on an event.
|
||||||
|
*
|
||||||
* Revision 1.5 2000/02/23 02:56:57 steve
|
* Revision 1.5 2000/02/23 02:56:57 steve
|
||||||
* Macintosh compilers do not support ident.
|
* Macintosh compilers do not support ident.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue