Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
d9f20043
Commit
d9f20043
authored
Jul 10, 2008
by
Simon Marlow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add threadStatus# primop, for querying the status of a ThreadId#
parent
a5b95b1f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
0 deletions
+41
-0
compiler/prelude/primops.txt.pp
compiler/prelude/primops.txt.pp
+5
-0
includes/Constants.h
includes/Constants.h
+1
-0
includes/StgMiscClosures.h
includes/StgMiscClosures.h
+1
-0
rts/Linker.c
rts/Linker.c
+1
-0
rts/PrimOps.cmm
rts/PrimOps.cmm
+33
-0
No files found.
compiler/prelude/primops.txt.pp
View file @
d9f20043
...
...
@@ -1531,6 +1531,11 @@ primop NoDuplicateOp "noDuplicate#" GenPrimOp
with
out_of_line = True
primop ThreadStatusOp "threadStatus#" GenPrimOp
ThreadId# -> State# RealWorld -> (# State# RealWorld, Int# #)
with
out_of_line = True
------------------------------------------------------------------------
section "Weak pointers"
------------------------------------------------------------------------
...
...
includes/Constants.h
View file @
d9f20043
...
...
@@ -193,6 +193,7 @@
/*
* Constants for the why_blocked field of a TSO
* NB. keep these in sync with GHC/Conc.lhs: threadStatus
*/
#define NotBlocked 0
#define BlockedOnMVar 1
...
...
includes/StgMiscClosures.h
View file @
d9f20043
...
...
@@ -585,6 +585,7 @@ RTS_FUN(unblockAsyncExceptionszh_fast);
RTS_FUN
(
myThreadIdzh_fast
);
RTS_FUN
(
labelThreadzh_fast
);
RTS_FUN
(
isCurrentThreadBoundzh_fast
);
RTS_FUN
(
threadStatuszh_fast
);
RTS_FUN
(
mkWeakzh_fast
);
RTS_FUN
(
finalizzeWeakzh_fast
);
...
...
rts/Linker.c
View file @
d9f20043
...
...
@@ -768,6 +768,7 @@ typedef struct _RtsSymbolVal {
SymX(stg_upd_frame_info) \
SymX(suspendThread) \
SymX(takeMVarzh_fast) \
SymX(threadStatuszh_fast) \
SymX(timesIntegerzh_fast) \
SymX(tryPutMVarzh_fast) \
SymX(tryTakeMVarzh_fast) \
...
...
rts/PrimOps.cmm
View file @
d9f20043
...
...
@@ -1034,6 +1034,39 @@ isCurrentThreadBoundzh_fast
RET_N
(
r
);
}
threadStatuszh_fast
{
/* args: R1 :: ThreadId# */
W_
tso
;
W_
why_blocked
;
W_
what_next
;
W_
ret
;
tso
=
R1
;
loop
:
if
(
TO_W_
(
StgTSO_what_next
(
tso
))
==
ThreadRelocated
)
{
tso
=
StgTSO__link
(
tso
);
goto
loop
;
}
what_next
=
TO_W_
(
StgTSO_what_next
(
tso
));
why_blocked
=
TO_W_
(
StgTSO_why_blocked
(
tso
));
// Note: these two reads are not atomic, so they might end up
// being inconsistent. It doesn't matter, since we
// only return one or the other. If we wanted to return the
// contents of block_info too, then we'd have to do some synchronisation.
if
(
what_next
==
ThreadComplete
)
{
ret
=
16
;
// NB. magic, matches up with GHC.Conc.threadStatus
}
else
{
if
(
what_next
==
ThreadKilled
)
{
ret
=
17
;
}
else
{
ret
=
why_blocked
;
}
}
RET_N
(
ret
);
}
/* -----------------------------------------------------------------------------
* TVar primitives
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment