Commit fbbed914 authored by stolz's avatar stolz
Browse files

[project @ 2002-06-26 08:18:38 by stolz]

- Make TSO "stable" again: The thread label was changing the size of the
   TSO if you were building a debugging-RTS, leading to binary
   incompatibility. Now we map TSOs to strings using Hash.c.

- API change for labelThread: Label arbitrary threads.
parent 7ca3bb74
----------------------------------------------------------------------- -----------------------------------------------------------------------
-- $Id: primops.txt.pp,v 1.20 2002/06/18 13:58:24 simonpj Exp $ -- $Id: primops.txt.pp,v 1.21 2002/06/26 08:18:38 stolz Exp $
-- --
-- Primitive Operations -- Primitive Operations
-- --
...@@ -1442,7 +1442,7 @@ primop MyThreadIdOp "myThreadId#" GenPrimOp ...@@ -1442,7 +1442,7 @@ primop MyThreadIdOp "myThreadId#" GenPrimOp
out_of_line = True out_of_line = True
primop LabelThreadOp "labelThread#" GenPrimOp primop LabelThreadOp "labelThread#" GenPrimOp
Addr# -> State# RealWorld -> State# RealWorld ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
with with
has_side_effects = True has_side_effects = True
out_of_line = True out_of_line = True
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: TSO.h,v 1.26 2002/04/10 11:43:44 stolz Exp $ * $Id: TSO.h,v 1.27 2002/06/26 08:18:41 stolz Exp $
* *
* (c) The GHC Team, 1998-1999 * (c) The GHC Team, 1998-1999
* *
...@@ -178,9 +178,6 @@ typedef struct StgTSO_ { ...@@ -178,9 +178,6 @@ typedef struct StgTSO_ {
StgTSOBlockInfo block_info; StgTSOBlockInfo block_info;
struct StgTSO_* blocked_exceptions; struct StgTSO_* blocked_exceptions;
StgThreadID id; StgThreadID id;
#ifdef DEBUG
char* label;
#endif
StgTSOTickyInfo ticky; StgTSOTickyInfo ticky;
StgTSOProfInfo prof; StgTSOProfInfo prof;
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: PrimOps.hc,v 1.98 2002/04/23 11:22:12 simonmar Exp $ * $Id: PrimOps.hc,v 1.99 2002/06/26 08:18:41 stolz Exp $
* *
* (c) The GHC Team, 1998-2000 * (c) The GHC Team, 1998-2000
* *
...@@ -1059,9 +1059,11 @@ FN_(myThreadIdzh_fast) ...@@ -1059,9 +1059,11 @@ FN_(myThreadIdzh_fast)
FN_(labelThreadzh_fast) FN_(labelThreadzh_fast)
{ {
FB_ FB_
/* args: R1.p = Addr# */ /* args:
R1.p = ThreadId#
R2.p = Addr# */
#ifdef DEBUG #ifdef DEBUG
STGCALL2(labelThread,CurrentTSO,(char *)R1.p); STGCALL2(labelThread,(StgTSO *)R1.p,(char *)R2.p);
#endif #endif
JMP_(ENTRY_CODE(Sp[0])); JMP_(ENTRY_CODE(Sp[0]));
FE_ FE_
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* $Id: RtsStartup.c,v 1.63 2002/05/11 00:16:12 sof Exp $ * $Id: RtsStartup.c,v 1.64 2002/06/26 08:18:41 stolz Exp $
* *
* (c) The GHC Team, 1998-2000 * (c) The GHC Team, 1998-2000
* *
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "Prelude.h" /* fixupRTStoPreludeRefs */ #include "Prelude.h" /* fixupRTStoPreludeRefs */
#include "HsFFI.h" #include "HsFFI.h"
#include "Linker.h" #include "Linker.h"
#include "ThreadLabels.h"
#if defined(RTS_GTK_FRONTPANEL) #if defined(RTS_GTK_FRONTPANEL)
#include "FrontPanel.h" #include "FrontPanel.h"
...@@ -156,6 +157,9 @@ startupHaskell(int argc, char *argv[], void (*init_root)(void)) ...@@ -156,6 +157,9 @@ startupHaskell(int argc, char *argv[], void (*init_root)(void))
/* initialise the stable pointer table */ /* initialise the stable pointer table */
initStablePtrTable(); initStablePtrTable();
/* initialise thread label table (tso->char*) */
initThreadLabelTable();
#if defined(PROFILING) || defined(DEBUG) #if defined(PROFILING) || defined(DEBUG)
initProfiling1(); initProfiling1();
#endif #endif
......
/* --------------------------------------------------------------------------- /* ---------------------------------------------------------------------------
* $Id: Schedule.c,v 1.145 2002/06/19 20:45:15 sof Exp $ * $Id: Schedule.c,v 1.146 2002/06/26 08:18:42 stolz Exp $
* *
* (c) The GHC Team, 1998-2000 * (c) The GHC Team, 1998-2000
* *
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
#include "Stats.h" #include "Stats.h"
#include "Itimer.h" #include "Itimer.h"
#include "Prelude.h" #include "Prelude.h"
#include "ThreadLabels.h"
#ifdef PROFILING #ifdef PROFILING
#include "Proftimer.h" #include "Proftimer.h"
#include "ProfHeap.h" #include "ProfHeap.h"
...@@ -451,8 +452,7 @@ schedule( void ) ...@@ -451,8 +452,7 @@ schedule( void )
m->stat = Success; m->stat = Success;
broadcastCondition(&m->wakeup); broadcastCondition(&m->wakeup);
#ifdef DEBUG #ifdef DEBUG
free(m->tso->label); removeThreadLabel(m->tso);
m->tso->label = NULL;
#endif #endif
break; break;
case ThreadKilled: case ThreadKilled:
...@@ -465,8 +465,7 @@ schedule( void ) ...@@ -465,8 +465,7 @@ schedule( void )
} }
broadcastCondition(&m->wakeup); broadcastCondition(&m->wakeup);
#ifdef DEBUG #ifdef DEBUG
free(m->tso->label); removeThreadLabel(m->tso);
m->tso->label = NULL;
#endif #endif
break; break;
default: default:
...@@ -488,8 +487,7 @@ schedule( void ) ...@@ -488,8 +487,7 @@ schedule( void )
if (m->tso->what_next == ThreadComplete if (m->tso->what_next == ThreadComplete
|| m->tso->what_next == ThreadKilled) { || m->tso->what_next == ThreadKilled) {
#ifdef DEBUG #ifdef DEBUG
free(m->tso->label); removeThreadLabel((StgWord)m->tso);
m->tso->label = NULL;
#endif #endif
main_threads = main_threads->link; main_threads = main_threads->link;
if (m->tso->what_next == ThreadComplete) { if (m->tso->what_next == ThreadComplete) {
...@@ -1648,14 +1646,13 @@ void labelThread(StgTSO *tso, char *label) ...@@ -1648,14 +1646,13 @@ void labelThread(StgTSO *tso, char *label)
/* Caveat: Once set, you can only set the thread name to "" */ /* Caveat: Once set, you can only set the thread name to "" */
len = strlen(label)+1; len = strlen(label)+1;
buf = realloc(tso->label,len); buf = malloc(len);
if (buf == NULL) { if (buf == NULL) {
fprintf(stderr,"insufficient memory for labelThread!\n"); fprintf(stderr,"insufficient memory for labelThread!\n");
free(tso->label);
tso->label = NULL;
} else } else
strncpy(buf,label,len); strncpy(buf,label,len);
tso->label = buf; /* Update will free the old memory for us */
updateThreadLabel((StgWord)tso,buf);
} }
#endif /* DEBUG */ #endif /* DEBUG */
...@@ -1720,10 +1717,6 @@ createThread(nat size) ...@@ -1720,10 +1717,6 @@ createThread(nat size)
#endif #endif
tso->what_next = ThreadEnterGHC; tso->what_next = ThreadEnterGHC;
#ifdef DEBUG
tso->label = NULL;
#endif
/* tso->id needs to be unique. For now we use a heavyweight mutex to /* tso->id needs to be unique. For now we use a heavyweight mutex to
* protect the increment operation on next_thread_id. * protect the increment operation on next_thread_id.
* In future, we could use an atomic increment instead. * In future, we could use an atomic increment instead.
...@@ -3583,6 +3576,7 @@ void ...@@ -3583,6 +3576,7 @@ void
printAllThreads(void) printAllThreads(void)
{ {
StgTSO *t; StgTSO *t;
void *label;
# if defined(GRAN) # if defined(GRAN)
char time_string[TIME_STR_LEN], node_str[NODE_STR_LEN]; char time_string[TIME_STR_LEN], node_str[NODE_STR_LEN];
...@@ -3601,8 +3595,9 @@ printAllThreads(void) ...@@ -3601,8 +3595,9 @@ printAllThreads(void)
# endif # endif
for (t = all_threads; t != END_TSO_QUEUE; t = t->global_link) { for (t = all_threads; t != END_TSO_QUEUE; t = t->global_link) {
fprintf(stderr, "\tthread %d ", t->id); fprintf(stderr, "\tthread %d @ %p ", t->id, (void *)t);
if (t->label) fprintf(stderr,"[\"%s\"] ",t->label); label = lookupThreadLabel((StgWord)t);
if (label) fprintf(stderr,"[\"%s\"] ",(char *)label);
printThreadStatus(t); printThreadStatus(t);
fprintf(stderr,"\n"); fprintf(stderr,"\n");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment