|
From: <jmk...@us...> - 2003-08-20 08:34:16
|
Update of /cvsroot/emc/rtapi/examples/shmem
In directory sc8-pr-cvs1:/tmp/cvs-serv10049/examples/shmem
Modified Files:
shmemtask.c shmemusr.c
Log Message:
moved proc stuff from rtapi_common.h to rtapi_proc.h, put most rtapi internal data in shared memory and put corresponding decls in rtapi_common.h
Index: shmemtask.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/shmem/shmemtask.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** shmemtask.c 14 Aug 2003 04:08:26 -0000 1.9
--- shmemtask.c 20 Aug 2003 03:16:20 -0000 1.10
***************
*** 11,15 ****
static int shmem_task; /* the task ID*/
static int shmem_mem; /* the shared memory ID */
! enum { SHMEM_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
enum { SHMEM_STACKSIZE = 1024 }; /* how big the stack is */
--- 11,16 ----
static int shmem_task; /* the task ID*/
static int shmem_mem; /* the shared memory ID */
! enum { TIMER_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
! enum { SHMEM_PERIOD_NSEC = 1000000 }; /* task period, in nanoseconds */
enum { SHMEM_STACKSIZE = 1024 }; /* how big the stack is */
***************
*** 35,38 ****
--- 36,40 ----
int retval;
int shmem_prio;
+ long period;
if (rtapi_init() != RTAPI_SUCCESS ) {
***************
*** 54,63 ****
shmem_struct->heartbeat = 0;
! /* set the base timer period */
! retval = rtapi_clock_set_period(SHMEM_PERIOD_NSEC);
! if ( retval < RTAPI_SUCCESS ) {
! rtapi_print( "shmemtask init: rtapi_clock_set_period returned %d\n", retval );
return -1;
}
/* set the task priority to lowest, since we only have one task */
--- 56,79 ----
shmem_struct->heartbeat = 0;
! /* is timer started? if so, what period? */
! period = rtapi_clock_set_period(0);
! if ( period == 0 ) {
! /* not running, start it */
! rtapi_print("shmemtask init: starting timer with period %ld\n", TIMER_PERIOD_NSEC);
! period = rtapi_clock_set_period(TIMER_PERIOD_NSEC);
! if (period < 0) {
! rtapi_print("shmemtask init: rtapi_clock_set_period failed with %ld\n",
! period);
! return -1;
! }
! }
! /* make sure period <= desired period (allow 1% roundoff error) */
! if ( period > (TIMER_PERIOD_NSEC+(TIMER_PERIOD_NSEC/100))) {
! /* timer period too long */
! rtapi_print("shmemtask init: clock period too long: %ld\n", period );
return -1;
}
+ rtapi_print("shmemtask init: desired clock %ld, actual %ld\n",
+ TIMER_PERIOD_NSEC, period );
/* set the task priority to lowest, since we only have one task */
Index: shmemusr.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/shmem/shmemusr.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** shmemusr.c 23 Jul 2003 01:22:49 -0000 1.2
--- shmemusr.c 20 Aug 2003 03:16:20 -0000 1.3
***************
*** 6,10 ****
static int key = SHMEM_KEY;
! static ulapi_shmem_handle shmem_mem;
static SHMEM_STRUCT *shmem_struct;
--- 6,10 ----
static int key = SHMEM_KEY;
! static int shmem_id;
static SHMEM_STRUCT *shmem_struct;
***************
*** 26,36 ****
/* allocate the shared memory structure */
! retval = ulapi_shmem_new( key, sizeof(SHMEM_STRUCT), &shmem_mem );
! if ( retval != ULAPI_SUCCESS ) {
! printf( "shmemusr main: ulapi_shmem_new returned %d\n", retval );
return -1;
}
! retval = ulapi_shmem_getptr( shmem_mem, (void **)&shmem_struct );
! if ( retval != ULAPI_SUCCESS ) {
printf( "shmemusr main: ulapi_shmem_getptr returned %d\n", retval );
return -1;
--- 26,36 ----
/* allocate the shared memory structure */
! shmem_id = ulapi_shmem_new( key, sizeof(SHMEM_STRUCT) );
! if (shmem_id < 0) {
! printf( "shmemusr main: ulapi_shmem_new returned %d\n", shmem_id );
return -1;
}
! retval = ulapi_shmem_getptr( shmem_id, (void **)&shmem_struct );
! if (retval != ULAPI_SUCCESS) {
printf( "shmemusr main: ulapi_shmem_getptr returned %d\n", retval );
return -1;
***************
*** 43,48 ****
}
! retval = ulapi_shmem_delete( shmem_mem );
! if ( retval != ULAPI_SUCCESS ) {
printf("shmemusr main: ulapi_free_shmem returned %d\n", retval );
return -1;
--- 43,48 ----
}
! retval = ulapi_shmem_delete( shmem_id );
! if (retval != ULAPI_SUCCESS) {
printf("shmemusr main: ulapi_free_shmem returned %d\n", retval );
return -1;
|