Commit 237d1510 authored by sof's avatar sof
Browse files

[project @ 2002-02-04 20:14:56 by sof]

simplified startup of this 'sub-system', initCapabilities() takes care of it all
parent 73064dcf
......@@ -23,6 +23,7 @@
#include "Capability.h"
static
void
initCapability( Capability *cap )
{
......@@ -32,31 +33,56 @@ initCapability( Capability *cap )
cap->f.stgUpdatePAP = (F_)__stg_update_PAP;
}
#ifdef SMP
static void initCapabilities_(nat n);
#endif
/*
*/
void
initCapabilities()
{
#if defined(SMP)
initCapabilities_(RtsFlags.ParFlags.nNodes);
#else
initCapability(&MainCapability);
#endif
return;
}
/* Free capability list.
* Locks required: sched_mutex.
*/
#if defined(SMP)
static Capability *free_capabilities; /* Available capabilities for running threads */
#endif
void grabCapability(Capability** cap)
{
#if !defined(SMP)
*cap = &MainCapability;
#else
*cap = free_capabilities;
free_capabilities = (*cap)->link;
rts_n_free_capabilities--;
#endif
}
void releaseCapability(Capability** cap)
{
#if defined(SMP)
(*cap)->link = free_capabilities;
free_capabilities = *cap;
rts_n_free_capabilities++;
#endif
return;
}
#if defined(SMP)
/* Allocate 'n' capabilities */
void
initCapabilities(nat n)
static void
initCapabilities_(nat n)
{
nat i;
Capability *cap, *prev;
......
......@@ -24,7 +24,14 @@
#include "RtsFlags.h"
/* ToDo: assume that RtsFlags.h has been included at usage sites of Capability.h? */
extern void initCapability(Capability* cap);
#if !defined(SMP)
Capability MainCapability;
#endif
extern void initCapabilities(void);
extern void grabCapability(Capability** cap);
extern void releaseCapability(Capability** cap);
#if defined(SMP)
extern nat rts_n_free_capabilities; /* total number of available capabilities */
......@@ -43,9 +50,6 @@ static inline rtsBool allFreeCapabilities()
return (rts_n_free_capabilities == RtsFlags.ParFlags.nNodes);
}
extern void initCapabilities(nat n);
extern void grabCapability(Capability** cap);
extern void releaseCapability(Capability** cap);
#endif /* SMP */
#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