Skip to content

Commit

Permalink
Able to disable thread self.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed May 27, 2002
1 parent 422754f commit bcd49b9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions vvp/vthread.cc
Expand Up @@ -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.72 2002/05/24 04:55:13 steve Exp $"
#ident "$Id: vthread.cc,v 1.73 2002/05/27 00:53:10 steve Exp $"
#endif

# include "vthread.h"
Expand Down Expand Up @@ -622,6 +622,8 @@ bool of_DISABLE(vthread_t thr, vvp_code_t cp)

struct vthread_s*head = scope->threads;

bool disabled_myself_flag = false;

while (head->scope_next != head) {
vthread_t tmp = head->scope_next;

Expand All @@ -631,10 +633,14 @@ bool of_DISABLE(vthread_t thr, vvp_code_t cp)

/* XXXX I don't support disabling threads with children. */
assert(tmp->child == 0);
assert(tmp != thr);
/* XXXX Not supported yet. */
/* XXXX Don't know how to disable waiting threads. */
assert(tmp->waiting_for_event == 0);

/* If I am disabling myself, that remember that fact so
that I can finish this statement differently. */
if (tmp == thr)
disabled_myself_flag = true;

tmp->pc = 0;
tmp->i_have_ended = 1;

Expand All @@ -655,7 +661,7 @@ bool of_DISABLE(vthread_t thr, vvp_code_t cp)
}
}

return true;
return ! disabled_myself_flag;
}

static void divide_bits(unsigned len, unsigned char*lbits,
Expand Down Expand Up @@ -1907,6 +1913,9 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)

/*
* $Log: vthread.cc,v $
* Revision 1.73 2002/05/27 00:53:10 steve
* Able to disable thread self.
*
* Revision 1.72 2002/05/24 04:55:13 steve
* Detect long division by zero.
*
Expand Down

0 comments on commit bcd49b9

Please sign in to comment.