/* -----------------------------------------------------------------------------
- * $Id: TSO.h,v 1.13 2000/03/17 13:30:23 simonmar Exp $
+ * $Id: TSO.h,v 1.14 2000/03/20 09:42:49 andy Exp $
*
* (c) The GHC Team, 1998-1999
*
StgClosure *closure;
struct StgTSO_ *tso;
int fd;
+#if defined(INTERPRETER) && !defined(HAVE_SETITIMER)
+ unsigned int target;
+#else
unsigned int delay;
+#endif
#if defined(PAR)
globalAddr ga;
#endif
* Copyright (c) 1994-1998.
*
* $RCSfile: Evaluator.c,v $
- * $Revision: 1.43 $
- * $Date: 2000/03/20 04:26:24 $
+ * $Revision: 1.44 $
+ * $Date: 2000/03/20 09:42:49 $
* ---------------------------------------------------------------------------*/
#include "Rts.h"
#include "ForeignCall.h"
#include "PrimOps.h" /* for __{encode,decode}{Float,Double} */
#include "Prelude.h"
+#include "ITimer.h"
#include "Evaluator.h"
#include "sainteger.h"
cap->rCurrentTSO->why_blocked = BlockedOnDelay;
ACQUIRE_LOCK(&sched_mutex);
+#if defined(HAVE_SETITIMER)
cap->rCurrentTSO->block_info.delay
= hugsBlock.delay + ticks_since_select;
+#else
+ cap->rCurrentTSO->block_info.target
+ = hugsBlock.delay + getourtimeofday();
+#endif
APPEND_TO_BLOCKED_QUEUE(cap->rCurrentTSO);
RELEASE_LOCK(&sched_mutex);
/* -----------------------------------------------------------------------------
- * $Id: Itimer.c,v 1.10 2000/03/14 01:43:27 sof Exp $
+ * $Id: Itimer.c,v 1.11 2000/03/20 09:42:49 andy Exp $
*
* (c) The GHC Team, 1995-1999
*
initialize_virtual_timer(nat ms)
{
# ifndef HAVE_SETITIMER
- fprintf(stderr, "No virtual timer on this system\n");
+ /* fprintf(stderr, "No virtual timer on this system\n"); */
return -1;
# else
struct itimerval it;
(void) sigprocmask(SIG_UNBLOCK, &signals, NULL);
}
#endif
+
+unsigned int
+getourtimeofday(void)
+{
+ struct timeval tv;
+ gettimeofday(&tv, (struct timezone *) NULL);
+ return (tv.tv_sec * 1000000 + tv.tv_usec);
+}
/* -----------------------------------------------------------------------------
- * $Id: Itimer.h,v 1.4 1999/08/25 16:11:48 simonmar Exp $
+ * $Id: Itimer.h,v 1.5 2000/03/20 09:42:49 andy Exp $
*
* (c) The GHC Team 1998-1999
*
int install_vtalrm_handler ( void );
void block_vtalrm_signal ( void );
void unblock_vtalrm_signal ( void );
+unsigned int getourtimeofday ( void );
/* -----------------------------------------------------------------------------
- * $Id: PrimOps.hc,v 1.46 2000/03/14 09:55:05 simonmar Exp $
+ * $Id: PrimOps.hc,v 1.47 2000/03/20 09:42:49 andy Exp $
*
* (c) The GHC Team, 1998-2000
*
#include "StablePriv.h"
#include "HeapStackCheck.h"
#include "StgRun.h"
+#include "ITimer.h"
#include "Prelude.h"
/* ** temporary **
/* Add on ticks_since_select, since these will be subtracted at
* the next awaitEvent call.
*/
+#if defined(HAVE_SETITIMER)
CurrentTSO->block_info.delay = R1.i + ticks_since_select;
+#else
+ CurrentTSO->block_info.target = R1.i + getourtimeofday();
+#endif
APPEND_TO_BLOCKED_QUEUE(CurrentTSO);
/* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.56 2000/03/17 14:37:21 simonmar Exp $
+ * $Id: Schedule.c,v 1.57 2000/03/20 09:42:50 andy Exp $
*
* (c) The GHC Team, 1998-2000
*
#include "Sanity.h"
#include "Stats.h"
#include "Sparks.h"
+#include "Itimer.h"
#include "Prelude.h"
#if defined(GRAN) || defined(PAR)
# include "GranSimRts.h"
fprintf(stderr,"blocked on write to fd %d", tso->block_info.fd);
break;
case BlockedOnDelay:
+#if defined(HAVE_SETITIMER)
fprintf(stderr,"blocked on delay of %d ms", tso->block_info.delay);
+#else
+ fprintf(stderr,"blocked on delay of %d ms",
+ tso->block_info.target - getourtimeofday());
+#endif
break;
case BlockedOnMVar:
fprintf(stderr,"blocked on an MVar");
#endif /* DEBUG */
+
//@node Index, , Debugging Routines, Main scheduling code
//@subsection Index
/* -----------------------------------------------------------------------------
- * $Id: Select.c,v 1.9 2000/03/16 17:24:08 simonmar Exp $
+ * $Id: Select.c,v 1.10 2000/03/20 09:42:50 andy Exp $
*
* (c) The GHC Team 1995-1999
*
case BlockedOnDelay:
{
- if (tso->block_info.delay < min)
- min = tso->block_info.delay;
+ int candidate; /* signed int is intentional */
+#if defined(HAVE_SETITIMER)
+ candidate = tso->block_info.delay;
+#else
+ candidate = tso->block_info.target - getourtimeofday();
+ if (candidate < 0) {
+ candidate = 0;
+ }
+#endif
+ if ((nat)candidate < min) {
+ min = candidate;
+ }
continue;
}
break;
case BlockedOnDelay:
- if (tso->block_info.delay > delta) {
- tso->block_info.delay -= delta;
- ready = 0;
- } else {
- tso->block_info.delay = 0;
- ready = 1;
+ {
+ int candidate; /* signed int is intentional */
+#if defined(HAVE_SETITIMER)
+ if (tso->block_info.delay > delta) {
+ tso->block_info.delay -= delta;
+ ready = 0;
+ } else {
+ tso->block_info.delay = 0;
+ ready = 1;
+ }
+#else
+ candidate = tso->block_info.target - getourtimeofday();
+ if (candidate < 0) {
+ candidate = 0;
+ }
+ if ((nat)candidate > delta) {
+ ready = 0;
+ } else {
+ ready = 1;
+ }
+#endif
+ break;
}
- break;
default:
barf("awaitEvent");