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


Functions

INT ss_thread_create (INT(*thread_func)(void *), void *param)
INT ss_thread_kill (INT 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 2253 of file system.c.

Referenced by bm_check_buffers(), bm_open_buffer(), cm_cleanup(), cm_get_watchdog_info(), cm_set_watchdog_params(), cm_shutdown(), db_open_database(), dm_buffer_create(), main(), scheduler(), send_event(), tr_prestart(), 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 2447 of file system.c.

Referenced by cm_shutdown(), and main().

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

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);
}
...
\encode
@param command Command to execute.
@return SS_SUCCESS or ss_exec() return code
*/
INT ss_system(char *command)
{







  system(command);
  return SS_SUCCESS;


}

/**dox***************************************************************/











































































                          /* DOXYGEN_SHOULD_SKIP_THIS */

/********************************************************************/
/**
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
\code
...
VX_TASK_SPAWN tsWatch = {"Watchdog", 100, 0, 2000,  (int) pDevice, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
thread_id = ss_thread_spawn((void *) taskWatch, &tsWatch);
if (thread_id == 0) {
  printf("cannot spawn taskWatch\n");
}
...
Example for Linux
...
thread_id = ss_thread_spawn((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 1676 of file system.c.

Referenced by dm_buffer_create().

INT ss_thread_kill INT  thread_id  ) 
 

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

...
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 1753 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 2320 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.3 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Suzannah Daviel - Doxygen - Peter Green - Greg Hackman - Gertjan Hofman - Paul Knowles - Rudi Meier - Glenn Moloney - Dave Morris - Konstantin Olchanski - Renee Poutissou - Andreas Suter - Piotr Adam Zolnierczuk