service_machine.anubis 2.62 KB

   
   An example of a service machine for 'http_server.anubis'. 
   
   
read tools/basis.anubis
   
 public define One
   print
     (
       AllocatorInfo i
     ) =
   if i is alloc_info(id,c,sms,nms,nfs,tms,tfs,nas, tss, tfss) then
   print(id+" "+(if c then " corrupted ! " else "")+
     " sms:"+sms+
     " nms:"+nms+
     " nfs:"+nfs+
     " tms:"+tms+
     " tfs:"+tfs+
     " nas:"+nas).
   
public define One
   print
     (
       AllocatorInfo i
     ) =
   if i is alloc_info(id,c,sms,nms,nfs,tms,tfs,nas, tss, tfss) then
   print(" nfs:"+nfs+
         " nas:"+nas).
   
public define One
   print
     (
       VirtualMachineState s
     ) =
   if s is 
     {
       not_used                          then should_not_happen(unique), 
       running                           then print("r"), 
       waiting_for_event                 then print("e"),
       waiting_for_condition             then print("c"), 
       waiting_for_completion            then print("x"), 
       finished                          then print("f"), 
       need_bigger_stack                 then print("s"),
       need_bigger_locked_files_stack    then print("l"),
       need_more_memory                  then print("m"),
       invalid_instruction               then print("i"), 
       invalid_IP                        then print("j")
     }.

define One
   print
     (
       VirtualMachineWorkSort   ws
     ) =
   print(
   if ws is 
     {
       computing     then "c",
       deleting      then "d", 
       equaling      then "e", 
       serializing   then "s",
       unserializing then "u"
     }).
   
define One
   print
     (
       List(VirtualMachineInfo) l
     ) =
   if l is 
     {
       [ ] then unique, 
       [h . t] then 
         if h is vm_info(mid,state,ws,sip,ip,ss,sp,l1,l5,l15) then
           print(to_decimal(mid)); print(state); print(ws); 
           print(to_decimal(ip)); 
           //(if state is running then print(to_decimal(ip)) else unique); 
           print(" "); 
           print(t)
     }.
   
public define One
   print
     (
       SystemInfo s
     ) =
   if s is sys_info(max_machine,vm_infos) then 
   print(vm_infos);
   print("  "); 
   print(allocator_info);
   print("   \r").
   

public define One
   show_system_info
     (
       One u
     ) = 
   print(system_info). 
   
   
public define One
   service_machine
     =
   sleep(1000); 
   show_system_info(unique);
   service_machine.
   
public define One
   service_machine
     (
       Var(Bool)   shutdown_required
     ) =
   if *shutdown_required then unique else
   sleep(1000); 
   show_system_info(unique);
   service_machine(shutdown_required).