task calls and forks push the thread event in the queue.
This commit is contained in:
parent
c787a36af2
commit
94cef20e49
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: schedule.cc,v 1.17 2002/05/04 03:03:17 steve Exp $"
|
||||
#ident "$Id: schedule.cc,v 1.18 2002/05/12 23:44:41 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "schedule.h"
|
||||
|
|
@ -189,6 +189,23 @@ static void schedule_event_(struct event_s*cur)
|
|||
}
|
||||
}
|
||||
}
|
||||
static void schedule_event_push_(struct event_s*cur)
|
||||
{
|
||||
assert(cur->delay == 0);
|
||||
cur->last = cur;
|
||||
|
||||
if (sched_list == 0) {
|
||||
sched_list = cur;
|
||||
cur->next = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sched_list->delay == 0)
|
||||
cur->last = sched_list->last;
|
||||
cur->next = sched_list;
|
||||
sched_list = cur;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The synch_list is managed as a doubly-linked circular list. There is
|
||||
|
|
@ -227,7 +244,7 @@ static struct event_s* pull_sync_event(void)
|
|||
return cur;
|
||||
}
|
||||
|
||||
void schedule_vthread(vthread_t thr, unsigned delay)
|
||||
void schedule_vthread(vthread_t thr, unsigned delay, bool push_flag)
|
||||
{
|
||||
struct event_s*cur = e_alloc();
|
||||
|
||||
|
|
@ -236,7 +253,16 @@ void schedule_vthread(vthread_t thr, unsigned delay)
|
|||
cur->type = TYPE_THREAD;
|
||||
vthread_mark_scheduled(thr);
|
||||
|
||||
schedule_event_(cur);
|
||||
if (push_flag && (delay == 0)) {
|
||||
/* Special case: If the delay is 0, the push_flag means
|
||||
I can push this event in front of everything. This is
|
||||
used by the %fork statement, for example, to perform
|
||||
task calls. */
|
||||
schedule_event_push_(cur);
|
||||
|
||||
} else {
|
||||
schedule_event_(cur);
|
||||
}
|
||||
}
|
||||
|
||||
void functor_s::schedule(unsigned delay)
|
||||
|
|
@ -372,6 +398,9 @@ void schedule_simulate(void)
|
|||
|
||||
/*
|
||||
* $Log: schedule.cc,v $
|
||||
* Revision 1.18 2002/05/12 23:44:41 steve
|
||||
* task calls and forks push the thread event in the queue.
|
||||
*
|
||||
* Revision 1.17 2002/05/04 03:03:17 steve
|
||||
* Add simulator event callbacks.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: schedule.h,v 1.9 2002/04/20 04:33:23 steve Exp $"
|
||||
#ident "$Id: schedule.h,v 1.10 2002/05/12 23:44:41 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -29,8 +29,13 @@
|
|||
* This causes a thread to be scheduled for execution. The schedule
|
||||
* puts the event into the event queue after any existing events for a
|
||||
* given time step. The delay is a relative time.
|
||||
*
|
||||
* If the delay is zero, the push_flag can be used to force the event
|
||||
* to the front of the queue. %fork uses this to get the thread
|
||||
* execution ahead of non-blocking assignments.
|
||||
*/
|
||||
extern void schedule_vthread(vthread_t thr, unsigned delay);
|
||||
extern void schedule_vthread(vthread_t thr, unsigned delay,
|
||||
bool push_flag =false);
|
||||
|
||||
/*
|
||||
* Create an assignment event. The val passed here will be assigned to
|
||||
|
|
@ -88,6 +93,9 @@ extern bool schedule_finished(void);
|
|||
|
||||
/*
|
||||
* $Log: schedule.h,v $
|
||||
* Revision 1.10 2002/05/12 23:44:41 steve
|
||||
* task calls and forks push the thread event in the queue.
|
||||
*
|
||||
* Revision 1.9 2002/04/20 04:33:23 steve
|
||||
* Support specified times in cbReadOnlySync, and
|
||||
* add support for cbReadWriteSync.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vthread.cc,v 1.69 2002/04/21 22:29:49 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.70 2002/05/12 23:44:41 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -641,7 +641,7 @@ bool of_DISABLE(vthread_t thr, vvp_code_t cp)
|
|||
if (tmp->schedule_parent_on_end) {
|
||||
/* If a parent is waiting in a %join, wake it up. */
|
||||
assert(tmp->parent);
|
||||
schedule_vthread(tmp->parent, 0);
|
||||
schedule_vthread(tmp->parent, 0, true);
|
||||
vthread_reap(tmp);
|
||||
|
||||
} else if (tmp->parent) {
|
||||
|
|
@ -980,7 +980,7 @@ bool of_END(vthread_t thr, vvp_code_t)
|
|||
%join for the parent. */
|
||||
if (thr->schedule_parent_on_end) {
|
||||
assert(thr->parent);
|
||||
schedule_vthread(thr->parent, 0);
|
||||
schedule_vthread(thr->parent, 0, true);
|
||||
vthread_reap(thr);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1021,7 +1021,7 @@ bool of_FORK(vthread_t thr, vvp_code_t cp)
|
|||
assert(child->child->parent == thr);
|
||||
child->child->parent = child;
|
||||
}
|
||||
schedule_vthread(child, 0);
|
||||
schedule_vthread(child, 0, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1884,6 +1884,9 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.70 2002/05/12 23:44:41 steve
|
||||
* task calls and forks push the thread event in the queue.
|
||||
*
|
||||
* Revision 1.69 2002/04/21 22:29:49 steve
|
||||
* Add the assign/d instruction for computed delays.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue