Commit 3fa80568 authored by sof's avatar sof
Browse files

[project @ 2002-02-12 15:34:25 by sof]

- give rts_n_free_capabilities an interpretation
  in threaded mode (possible values: 0,1)
- noFreeCapabilities() -? noCapabilities()
parent 2cc5b907
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
Capability MainCapability; /* for non-SMP, we have one global capability */ Capability MainCapability; /* for non-SMP, we have one global capability */
#endif #endif
nat rts_n_free_capabilities;
static static
void void
initCapability( Capability *cap ) initCapability( Capability *cap )
...@@ -64,6 +66,7 @@ static Capability *free_capabilities; /* Available capabilities for running thre ...@@ -64,6 +66,7 @@ static Capability *free_capabilities; /* Available capabilities for running thre
void grabCapability(Capability** cap) void grabCapability(Capability** cap)
{ {
#if !defined(SMP) #if !defined(SMP)
rts_n_free_capabilities = 0;
*cap = &MainCapability; *cap = &MainCapability;
#else #else
*cap = free_capabilities; *cap = free_capabilities;
...@@ -79,6 +82,7 @@ void releaseCapability(Capability* cap) ...@@ -79,6 +82,7 @@ void releaseCapability(Capability* cap)
free_capabilities = cap; free_capabilities = cap;
rts_n_free_capabilities++; rts_n_free_capabilities++;
#endif #endif
rts_n_free_capabilities = 1;
return; return;
} }
......
...@@ -32,7 +32,7 @@ extern void initCapabilities(void); ...@@ -32,7 +32,7 @@ extern void initCapabilities(void);
extern void grabCapability(Capability** cap); extern void grabCapability(Capability** cap);
extern void releaseCapability(Capability* cap); extern void releaseCapability(Capability* cap);
#if defined(SMP) #if defined(RTS_SUPPORTS_THREADS)
extern nat rts_n_free_capabilities; /* total number of available capabilities */ extern nat rts_n_free_capabilities; /* total number of available capabilities */
static inline nat getFreeCapabilities() static inline nat getFreeCapabilities()
...@@ -40,16 +40,20 @@ static inline nat getFreeCapabilities() ...@@ -40,16 +40,20 @@ static inline nat getFreeCapabilities()
return rts_n_free_capabilities; return rts_n_free_capabilities;
} }
static inline rtsBool noFreeCapabilities() static inline rtsBool noCapabilities()
{ {
return (rts_n_free_capabilities == 0); return (rts_n_free_capabilities == 0);
} }
static inline rtsBool allFreeCapabilities() static inline rtsBool allFreeCapabilities()
{ {
# if defined(SMP)
return (rts_n_free_capabilities == RtsFlags.ParFlags.nNodes); return (rts_n_free_capabilities == RtsFlags.ParFlags.nNodes);
# else
return (rts_n_free_capabilities == 1);
# endif
} }
#endif /* SMP */ #endif /* RTS_SUPPORTS_THREADS */
#endif /* __CAPABILITY_H__ */ #endif /* __CAPABILITY_H__ */
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