|
From: <jmk...@us...> - 2003-08-16 20:48:56
|
Update of /cvsroot/emc/rtapi/src/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv22692/src/rtapi
Modified Files:
rtai_rtapi.c rtapi.h rtapi_app.h
Log Message:
added sleep() functions
Index: rtai_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtai_rtapi.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** rtai_rtapi.c 16 Aug 2003 20:08:33 -0000 1.26
--- rtai_rtapi.c 16 Aug 2003 20:29:39 -0000 1.27
***************
*** 127,141 ****
static int fifo_usage_count = 0;
static int int_usage_count = 0;
/* Flag used to keep track of timer state */
static int timer_running = 0;
! static long int timer_period = 0;
/* global used for message printing */
int rtapi_msg_level;
- char *rev_str; /* version of RTAPI */
-
static int msg = 7; /* short name, for use in insmod command */
MODULE_PARM(msg, "i");
! MODULE_PARM_DESC(msg, "Verbosity, higher value = more messages (default=7)");
! MODULE_DESCRIPTION("Portable realtime API for RTAI");
MODULE_AUTHOR("John Kasunich, Fred Proctor, & Paul Corner");
--- 127,148 ----
static int fifo_usage_count = 0;
static int int_usage_count = 0;
+
/* Flag used to keep track of timer state */
static int timer_running = 0;
! static unsigned long timer_period = 0;
! #define DEFAULT_MAX_SLEEP 10000
! static unsigned long max_sleep = DEFAULT_MAX_SLEEP;
!
! /* misc vars */
! static char *rev_str; /* version of RTAPI */
!
/* global used for message printing */
int rtapi_msg_level;
static int msg = 7; /* short name, for use in insmod command */
MODULE_PARM(msg, "i");
! MODULE_PARM_DESC(msg, "debug message level (default=7)");
!
! /* other module information */
! MODULE_DESCRIPTION("Portable Real Time API for RTAI");
MODULE_AUTHOR("John Kasunich, Fred Proctor, & Paul Corner");
***************
*** 451,454 ****
--- 458,462 ----
rt_free_timer();
timer_period = 0;
+ max_sleep = DEFAULT_MAX_SLEEP;
timer_running = 0;
}
***************
*** 511,514 ****
--- 519,524 ----
int_usage_count = 0;
timer_running = 0;
+ max_sleep = DEFAULT_MAX_SLEEP;
+ timer_period = 0;
rt_linux_use_fpu(1);
/* done */
***************
*** 585,588 ****
--- 595,599 ----
rt_free_timer();
timer_period = 0;
+ max_sleep = DEFAULT_MAX_SLEEP;
timer_running = 0;
}
***************
*** 647,651 ****
"RTAPI: clock_set_period requested: %d actual: %d\n",
nsecs, timer_period);
!
return timer_period;
}
--- 658,662 ----
"RTAPI: clock_set_period requested: %d actual: %d\n",
nsecs, timer_period);
! max_sleep = timer_period / 4;
return timer_period;
}
***************
*** 656,659 ****
--- 667,686 ----
return rt_get_time_ns();
}
+
+
+ void rtapi_sleep(unsigned long int nsec)
+ {
+ if ( nsec > max_sleep ) {
+ nsec = max_sleep;
+ }
+ rt_busy_sleep(nsec);
+ }
+
+
+ unsigned long int rtapi_sleep_max(void)
+ {
+ return max_sleep;
+ }
+
/***********************************************************************
Index: rtapi.h
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** rtapi.h 15 Aug 2003 20:45:13 -0000 1.21
--- rtapi.h 16 Aug 2003 20:29:39 -0000 1.22
***************
*** 133,139 ****
* nothing, but it is monotonically increasing (at least for the first *
* 200 years or so), and can be used to schedule future events, or to *
! * time the duration of some activity. Returns a 2^63 value. */
extern long long int rtapi_get_time(void);
--- 133,153 ----
* nothing, but it is monotonically increasing (at least for the first *
* 200 years or so), and can be used to schedule future events, or to *
! * time the duration of some activity. Returns a 2^63 value. The *
! * resolution of the returned value may be as good as one nano-second, *
! * or as poor as several microseconds. */
extern long long int rtapi_get_time(void);
+
+ /** rtapi_sleep() is a simple delay. It is intended only for short *
+ * delays, since it simply loops, wasting CPU cycles. 'nsec' is the *
+ * desired delay, in nano-seconds. 'rtapi_sleep_max() returns the max *
+ * delay permitted (usually approximately 1/4 of the timer period). *
+ * Any call to 'rtapi_sleep()' requesting a delay longer than the max *
+ * will delay for the max time only. 'rtapi_sleep_max()' should be *
+ * called befure using 'rtapi_sleep()' to make sure the required delays *
+ * can be achieved. */
+
+ extern void rtapi_sleep(unsigned long int nsec);
+ extern unsigned long int rtapi_sleep_max(void);
Index: rtapi_app.h
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi_app.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** rtapi_app.h 16 Aug 2003 20:08:33 -0000 1.3
--- rtapi_app.h 16 Aug 2003 20:29:39 -0000 1.4
***************
*** 14,19 ****
#define rtapi_app_exit(a) cleanup_module(a)
- extern int rtapi_app_init(void);
- extern void rtapi_app_return(void);
-
#endif /* RTAPI_APP_H */
--- 14,16 ----
|