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) |
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); ...
Definition at line 2190 of file system.c.
Referenced by bm_check_buffers(), bm_open_buffer(), check_polled_events(), close_buffers(), cm_cleanup(), cm_get_watchdog_info(), cm_set_watchdog_params(), cm_shutdown(), db_open_database(), dm_buffer_create(), sc_thread(), scan_fragment(), scheduler(), send_event(), and tr_stop().
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()
millisec | Time in milliseconds to sleep. Zero means infinite (until another process calls ss_wake) |
Definition at line 2422 of file system.c.
Referenced by cm_shutdown(), device_driver(), main(), rb_get_rp(), rb_get_wp(), read_trigger_event(), readout_thread(), 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); } ...
command | Command to execute. |
Definition at line 1503 of file system.c.
Referenced by al_check(), and 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"); } ...
... midas_thread_t thread_id = ss_thread_create((void *) taskWatch, pDevice); if (thread_id == 0) { printf("cannot spawn taskWatch\n"); } ...
(*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 |
Definition at line 1629 of file system.c.
Referenced by device_driver(), and 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); ...
thread_id | the thread id of the thread to be killed. |
Definition at line 1703 of file system.c.
Referenced by device_driver().
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); ...
Definition at line 2257 of file system.c.
Referenced by al_check(), 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().