<Other public methods of off_Processor. >+= (<-U) [<-D->]
// Returns a navigator for Processors.
off_Navigator *get_navigator(void) { return NULL; }
<Off processor dependencies. >+= (U->) [<-D->] #include <klib/nav.h> // for off_Navigator et al.
\subsubsection{Processor inspection}
We have to implement get_url and nameof.
<Other public methods of off_Processor. >+= (<-U) [<-D->]
// Get the processor URL.
const char *get_url(void);
// Returns the processor name.
const char *nameof(void);
The URL for a processor is that of its node with proc.html
appended. We use a new member, a character array initialized the very
first time it is needed.
<Other private members of off_Processor. >+= (<-U) [<-D->]
static char *p_url; // URL for this Processor.
<Off processor static members. >+= (U->) [<-D] char *off_Processor::p_url=NULL; // URL for this Processor.
<off_Processor::get_url implementation. >= (U->)
// Get the Processor URL.
const char *off_Processor::get_url(void)
{
assert(valid());
if (!p_url){
p_url=new char[strlen(nd.get_url())+strlen(OFF_PROC_URL)+1]; //+1 for \0
if (p_url){
strcpy(p_url,nd.get_url());
strcat(p_url,OFF_PROC_URL);
}
}
return p_url;
}
Where he have to define the relative URL for processors.
<Off source code urls. >= [D->] const char OFF_PROC_URL[]="/proc.html";
<Off processor dependencies. >+= (U->) [<-D] #include <klib/url.h> // for OFF_PROC_URL #include <string.h> // for strcat strdup et al
The name for a processor is that of its node complemented with a
little suffix. The implementation is almost the same of get_url,
however, the name is not shared among processors in the same node
(i.e. it is not static).
<off_Processor::nameof implementation. >= (U->)
// Returns the processor name.
const char *off_Processor::nameof(void)
{
assert(valid());
if (!p_name){
p_name = new char[strlen(nd.nameof())+strlen("/proc")+9]; // for N...N\0
if (p_name){
char number[9];
strcpy(p_name,nd.nameof());
strcat(p_name,"/proc");
sprintf(number,"%08x",(natural_t)get_id());
strcat(p_name,number);
}
}
return p_name;
}
<Other private members of off_Processor. >+= (<-U) [<-D]
char *p_name; // name for this Processor.
<Initialize other aggregate members of off_Processor. >+= (<-U) [<-D]
p_name(NULL)
\subsubsection{Run queue slot inspection}
We need get_rurl and get_url_holder for slots to support
ResUnit::get_url.
<Other protected methods of off_RunqSlot. >= (<-U) [D->]
// Get the slot
virtual const char *get_rurl(void) const;
// Returns the slot name.
virtual char *&get_url_holder(void);
<off_RunqSlot::get_rurl implementation. >= (U->)
// Get the slot
const char *off_RunqSlot::get_rurl(void) const { return OFF_RUNQSL_URL; }
Where he have to define the relative URL for slots.
<Off source code urls. >+= [<-D] const char OFF_RUNQSL_URL[]="#RunqSlot";
DefinesOFF_RUNQSL_URL(links are to index).
<Off run queue slot dependencies. >+= (U->) [<-D] #include <klib/url.h> // for OFF_RUNQSL_URL #include <stdio.h> // for sprintf et al
URLs are the same for all slots.
<Other private members of off_RunqSlot. >= (<-U)
static char *r_url; // URL for this slot.
<off_RunqSlot::get_url_holder implementation. >= (U->)
char *&off_RunqSlot::get_url_holder(void) { return r_url; }
<Off run queue slot static members. >= (U->) char *off_RunqSlot::r_url=NULL; // URL for slots.