[project @ 2005-07-09 00:13:14 by igloo]
[ghc-hetmet.git] / ghc / rts / Capability.h
index e615035..5f1649e 100644 (file)
 #ifndef __CAPABILITY_H__
 #define __CAPABILITY_H__
 
+#include "RtsFlags.h"
+
+// All the capabilities
+extern Capability *capabilities;
+
 // Initialised the available capabilities.
 //
 extern void initCapabilities( void );
@@ -35,6 +40,12 @@ extern void releaseCapability( Capability* cap );
 //
 extern void threadRunnable ( void );
 
+// Return the capability that I own.
+// 
+extern Capability *myCapability (void);
+
+extern void prodWorker ( void );
+
 #ifdef RTS_SUPPORTS_THREADS
 // Gives up the current capability IFF there is a higher-priority
 // thread waiting for it.  This happens in one of two ways:
@@ -48,7 +59,7 @@ extern void threadRunnable ( void );
 // current worker thread should then re-acquire it using
 // waitForCapability().
 //
-extern void yieldCapability( Capability **pCap );
+extern void yieldCapability( Capability** pCap, Condition *cond );
 
 // Acquires a capability for doing some work.
 //
@@ -80,6 +91,9 @@ extern void passCapability(Condition *pTargetThreadCond);
 extern void passCapabilityToWorker( void );
 
 extern nat rts_n_free_capabilities;  
+
+extern Capability *free_capabilities;
+
 /* number of worker threads waiting for a return capability
  */
 extern nat rts_n_waiting_workers;
@@ -101,7 +115,11 @@ static inline rtsBool noCapabilities (void)
 
 static inline rtsBool allFreeCapabilities (void)
 {
+#if defined(SMP)
+  return (rts_n_free_capabilities == RTS_DEREF(RtsFlags).ParFlags.nNodes);
+#else
   return (rts_n_free_capabilities == 1);
+#endif
 }
 
 #else // !RTS_SUPPORTS_THREADS
@@ -111,6 +129,6 @@ static inline rtsBool allFreeCapabilities (void)
 //
 extern void grabCapability( Capability **pCap );
 
-#endif // !RTS_SUPPORTS_THREADS
+#endif /* !RTS_SUPPORTS_THREADS */
 
 #endif /* __CAPABILITY_H__ */