ShtlSrv, is to allocate
shuttles, thus it maintains a shuttle allocator.
<Off shuttle server. >= (U->)
// A shuttle server
//
class off_ShtlSrv: public off_AbsCompResource {
public:
// Returns a pointer to the shuttle allocator.
virtual off_ShtlAllocator *get_allocator(void);
<Other public methods of off_ShtlSrv. >
protected:
<Other protected methods of off_ShtlSrv. >
private:
static off_ShtlAllocator s_alloc; // Shuttle allocator.
<Other private members of off_ShtlSrv. >
};
Definesoff_ShtlSrv(links are to index).
<Off shuttle server dependencies. >= (U->) [D->] #include <klib/AbsCompResource.h> // for off_AbsCompResource #include <shtl/ShtlAllocator.h> // for allocated off_ShtlAllocator #include <shtl/Shtl.h> // for off_Shtl
<Off shuttle server static members. >= (U->) [D->] off_ShtlAllocator off_ShtlSrv::s_alloc; // Shuttle allocator.
<off_ShtlSrv::get_allocator implementation. >= (U->)
// Returns a pointer to the shuttle allocator.
off_ShtlAllocator *off_ShtlSrv::get_allocator(void)
{
return &s_alloc;
}
Being a subclass of CompResource we must implement
make_available and is_local.
<Other public methods of off_ShtlSrv. >= (<-U) [D->]
// We may wish to cache a resource unit.
// Returns error code if the resource is not available. Zero otherwise.
inline err_t make_available(off_id_t &u);
<off_ShtlSrv::make_availableimplementation. >= (U->) // We may wish to cache a resource unit. // Returns error code if the resource is not available. Zero otherwise. inline err_t off_ShtlSrv::make_available(off_id_t &u) { <Body ofoff_CompResource::make_available. > }
<Other public methods of off_ShtlSrv. >+= (<-U) [<-D->]
// Is this identifier a local one?
inline boolean_t is_local(const off_shtl_id_t &s);
<off_ShtlSrv::is_local implementation. >= (U->)
// Is this identifier a local one?
inline boolean_t off_ShtlSrv::is_local(const off_shtl_id_t &s)
{
return ( s.i_slot <= s_alloc.get_length() &&
(s_alloc+(natural_t)s.i_slot)->l_shtl.get_id() == s );
}
<Off shuttle server dependencies. >+= (U->) [<-D->] #include <klib/ids.h> // for OFF_PRTL_NULL et al. #include <flux/types.h> // for boolean_t natural_t et al. #include <klib/err.h> // for err_t #include <klib/prot.h> // for off_Protection #include <klib/Magic.h> // for magic numbers
Initially, shuttle servers are created with default values for its members.
<Other public methods of off_ShtlSrv. >+= (<-U) [<-D->]
// Creates a shuttle server.
off_ShtlSrv(void);
There is a single instance per system.
<Off shuttle server exported variables. >= (U->) extern off_ShtlSrv shtl; // Shuttle server instance for this node.
<Off shuttle server global variables. >= (U->) off_ShtlSrv shtl; // Shuttle oserver instance for this node.
<off_ShtlSrv::off_ShtlSrvimplementation. >= (U->) // Creates a shuttle server. off_ShtlSrv::off_ShtlSrv(void) : off_AbsCompResource(off_Protection(), OFF_PRTL_NULL, OFF_ID_NULL, OFF_MAGIC_SHTLSRV), <Initialize other aggregate members ofoff_ShtlSrv. > { ; }
Where the magic number has to be defined.
<Off magic numbers. >= [D->] OFF_MAGIC_SHTLSRV, // ShtlSrv magic nb.
We can now add another case to the implementation of
Magic::nameof.
<off_Magic::nameofcase form_numbers. >= [D->] case OFF_MAGIC_SHTLSRV: return "off_ShtlSrv";
Shuttle server users can check their references to processors using this method.
<Other public methods of off_ShtlSrv. >+= (<-U) [<-D->]
// Does this look like a ShtlSrv?
inline boolean_t valid(void) const;
<off_ShtlSrv::valid implementation. >= (U->)
// Does this look like a ShtlSrv?
inline boolean_t off_ShtlSrv::valid(void) const
{ return get_magic() == OFF_MAGIC_SHTLSRV; }
After instantiation, start should be used to start shuttle server
operation.
<Other public methods of off_ShtlSrv. >+= (<-U) [<-D->]
// Starts normal operation for this shuttle server.
err_t start( const off_mdepShtlSrv &mdep, const off_id_t &id );
<Off shuttle server dependencies. >+= (U->) [<-D->] #include <shtl/mdep/mShtlSrv.h> // for off_mdepShtlSrv
<off_ShtlSrv::startimplementation. >= (U->) // Starts normal operation for this shuttle server. err_t off_ShtlSrv::start( const off_mdepShtlSrv &mdep, const off_id_t &id ) { assert(valid()); set_id(id); <InitializeShtlSrv::s_alloc. > <Start other members ofoff_ShtlSrvaccording tomdep. > kcout<< "Shtl #" << id << " started."<< nl; return EOK; }
<Off shuttle server dependencies. >+= (U->) [<-D->] #include <assert.h> // for assert #include <klib/str.h> // for kcout.
A new member, s_mdep stores any boot time machine dependent
information which might be needed by the shuttle server.
<Other private members of off_ShtlSrv. >= (<-U) [D->]
off_mdepShtlSrv s_mdep; // Machine dependent info.
<Start other members ofoff_ShtlSrvaccording tomdep. >= (<-U) s_mdep=mdep;
Initially, before the shuttle server is started, it is initialized with default values.
<Initialize other aggregate members of off_ShtlSrv. >= (<-U) [D->]
s_mdep(0),