4 ** Made by (Miguel marciano)
5 ** Login <miguel@namir.ctr.unican.es>
7 ** Started on Thu Nov 8 16:22:18 2007 Miguel marciano
8 ** Last update Sun May 12 01:17:25 2002 Speed Blue
18 #include "frsh_debug.h"
19 #include "frsh_error.h"
25 struct timespec past_time = {-1, 1};
26 struct timespec current_time = {-1, 1};
27 fosa_timer_id_t timer;
29 frsh_signal_t signal_set[1];
30 frsh_signal_info_t signal_info;
31 frsh_signal_t signal_received;
33 int my_test_value = 42;
34 struct timespec eat_time = {2, 0};
37 memset(¤t_time, 0, sizeof(current_time) );
38 memset(&signal_info, 0, sizeof(signal_info) );
39 memset(&timer, 0, sizeof(timer) );
40 memset(&signal_set, 0, sizeof(signal_set) );
41 memset(&signal_received, 0, sizeof(signal_received) );
44 /* We block the signals that we are going to process */
45 /*****************************************************/
46 signal_set[0] = FRSH_SCHEDULER_SIGNAL;
47 terror = fosa_set_accepted_signals(signal_set, 1);
48 if (terror != 0) exit(1);
52 /* We create a timer based on the FOSA_CLOCK_REALTIME */
53 /******************************************************/
54 signal_info.sival_int = my_test_value;
55 terror = fosa_timer_create(FOSA_CLOCK_REALTIME, FRSH_SCHEDULER_SIGNAL, signal_info, &timer);
56 if (terror != 0) exit(1);
58 /* I get the time BEFORE doing the eat */
59 /***************************************/
60 terror = fosa_clock_get_time(FOSA_CLOCK_REALTIME, &past_time);
61 if (terror != 0) exit(1);
62 printf("Current time: %d sec, %d nsec\n", past_time.tv_sec, past_time.tv_nsec);
64 /* Now I do some work for some secs */
65 /************************************/
68 /* I read the time again */
69 /*************************/
70 terror = fosa_clock_get_time(FOSA_CLOCK_REALTIME, ¤t_time);
71 if (terror != 0) exit(1);
72 printf("Current time: %d sec, %d nsec\n", current_time.tv_sec, current_time.tv_nsec);
74 /* I arm the timer to the past */
75 /* Since we have blocked this signal, the signal should be stored */
76 /******************************************************************/
77 printf("Arming the timer\n");
78 terror = fosa_timer_arm(timer, true, &past_time);
81 /* Now I do the sigwait */
82 /************************/
83 printf("Waiting for the signal\n");
84 terror = fosa_signal_wait(signal_set, 1, &signal_received, &signal_info);
85 if (terror != 0) exit(1);
87 printf("Signal accepted!!!\n");