System Functions (ss_xxx)
[The msystem.h & system.c]


Functions

INT ss_system (char *command)
midas_thread_t ss_thread_create (INT(*thread_func)(void *), void *param)
INT ss_thread_kill (midas_thread_t thread_id)
DWORD ss_millitime ()
DWORD ss_time ()
INT ss_sleep (INT millisec)


Function Documentation

DWORD ss_millitime  ) 
 

Returns the actual time in milliseconds with an arbitrary origin. This time may only be used to calculate relative times.

Overruns in the 32 bit value don't hurt since in a subtraction calculated with 32 bit accuracy this overrun cancels (you may think about!)..

...
DWORD start, stop:
start = ss_millitime();
  < do operations >
stop = ss_millitime();
printf("Operation took %1.3lf seconds\n",(stop-start)/1000.0);
...
Returns:
millisecond time stamp.

Definition at line 1989 of file system.c.

Referenced by bm_check_buffers(), bm_open_buffer(), close_buffers(), cm_cleanup(), cm_get_watchdog_info(), cm_set_watchdog_params(), cm_shutdown(), db_open_database(), dm_buffer_create(), register_equipment(), scan_fragment(), scheduler(), send_event(), and tr_stop().

INT ss_sleep INT  millisec  ) 
 

Suspend the calling process for a certain time.

The function is similar to the sleep() function, but has a resolution of one milliseconds. Under VxWorks the resolution is 1/60 of a second. It uses the socket select() function with a time-out. See examples in ss_time()

Parameters:
millisec Time in milliseconds to sleep. Zero means infinite (until another process calls ss_wake)
Returns:
SS_SUCCESS

Definition at line 2221 of file system.c.

Referenced by cm_shutdown(), main(), and register_equipment().

INT ss_system char *  command  ) 
 

Execute command in a separate process, close all open file descriptors invoke ss_exec() and ignore pid.

{ ...
  char cmd[256];
  sprintf(cmd,"%s %s %i %s/%s %1.3lf %d",lazy.commandAfter,
     lazy.backlabel, lazyst.nfiles, lazy.path, lazyst.backfile,
     lazyst.file_size/1024.0/1024.0, blockn);
  cm_msg(MINFO,"Lazy","Exec post file write script:%s",cmd);
  ss_system(cmd);
}
...
Parameters:
command Command to execute.
Returns:
SS_SUCCESS or ss_exec() return code

Definition at line 1303 of file system.c.

Referenced by cm_transition().

midas_thread_t ss_thread_create INT(*)(void *)  thread_func,
void *  param
 

Creates and returns a new thread of execution.

Note the difference when calling from vxWorks versus Linux and Windows. The parameter pointer for a vxWorks call is a VX_TASK_SPAWN structure, whereas for Linux and Windows it is a void pointer. Early versions returned SS_SUCCESS or SS_NO_THREAD instead of thread ID.

Example for VxWorks

...
VX_TASK_SPAWN tsWatch = {"Watchdog", 100, 0, 2000,  (int) pDevice, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
midas_thread_t thread_id = ss_thread_create((void *) taskWatch, &tsWatch);
if (thread_id == 0) {
  printf("cannot spawn taskWatch\n");
}
...
Example for Linux
...
midas_thread_t thread_id = ss_thread_create((void *) taskWatch, pDevice);
if (thread_id == 0) {
  printf("cannot spawn taskWatch\n");
}
...
Parameters:
(*thread_func) Thread function to create.
param a pointer to a VX_TASK_SPAWN structure for vxWorks and a void pointer for Unix and Windows
Returns:
the new thread id or zero on error

Definition at line 1429 of file system.c.

Referenced by dm_buffer_create().

INT ss_thread_kill midas_thread_t  thread_id  ) 
 

Destroys the thread identified by the passed thread id. The thread id is returned by ss_thread_create() on creation.

...
midas_thread_t thread_id = ss_thread_create((void *) taskWatch, pDevice);
if (thread_id == 0) {
  printf("cannot spawn taskWatch\n");
}
...
ss_thread_kill(thread_id);
...
Parameters:
thread_id the thread id of the thread to be killed.
Returns:
SS_SUCCESS if no error, else SS_NO_THREAD

Definition at line 1503 of file system.c.

DWORD ss_time  ) 
 

Returns the actual time in seconds since 1.1.1970 UTC.

...
DWORD start, stop:
start = ss_time();
  ss_sleep(12000);
stop = ss_time();
printf("Operation took %1.3lf seconds\n",stop-start);
...
Returns:
Time in seconds

Definition at line 2056 of file system.c.

Referenced by al_trigger_alarm(), bm_compose_event(), cm_synchronize(), cm_time(), cm_yield(), db_get_key_time(), db_set_data(), db_set_data_index(), db_set_value(), scheduler(), and send_event().


Midas DOC Version 1.9.5 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk