@@ -1694,18 +1694,31 @@ int hal_export_funct(const char *name, void (*funct) (void *, long),
1694
1694
new -> runtime = 0 ;
1695
1695
new -> maxtime = 0 ;
1696
1696
new -> maxtime_increased = 0 ;
1697
+
1698
+ /* at this point we have a new function and can yield the mutex */
1699
+ rtapi_mutex_give (& (hal_data -> mutex ));
1700
+
1701
+ /* create a pin with the function's runtime in it */
1702
+ if (hal_pin_s32_newf (HAL_OUT , & (new -> runtime ), comp_id ,"%s.time" ,name )) {
1703
+ rtapi_print_msg (RTAPI_MSG_ERR ,
1704
+ "HAL: ERROR: fail to create pin '%s.time'\n" , name );
1705
+ return - EINVAL ;
1706
+ }
1707
+ * (new -> runtime ) = 0 ;
1708
+
1697
1709
/* note that failure to successfully create the following params
1698
1710
does not cause the "export_funct()" call to fail - they are
1699
1711
for debugging and testing use only */
1700
- /* create a parameter with the function's runtime in it */
1701
- rtapi_snprintf (buf , sizeof (buf ), "%s.time" , name );
1702
- hal_param_s32_new (buf , HAL_RO , & (new -> runtime ), comp_id );
1703
1712
/* create a parameter with the function's maximum runtime in it */
1704
1713
rtapi_snprintf (buf , sizeof (buf ), "%s.tmax" , name );
1714
+ new -> maxtime = 0 ;
1705
1715
hal_param_s32_new (buf , HAL_RW , & (new -> maxtime ), comp_id );
1716
+
1706
1717
/* create a parameter with the function's maximum runtime in it */
1707
1718
rtapi_snprintf (buf , sizeof (buf ), "%s.tmax-increased" , name );
1719
+ new -> maxtime_increased = 0 ;
1708
1720
hal_param_bit_new (buf , HAL_RO , & (new -> maxtime_increased ), comp_id );
1721
+
1709
1722
return 0 ;
1710
1723
}
1711
1724
@@ -2831,9 +2844,9 @@ static void thread_task(void *arg)
2831
2844
/* point to function structure */
2832
2845
funct = SHMPTR (funct_entry -> funct_ptr );
2833
2846
/* update execution time data */
2834
- funct -> runtime = (hal_s32_t )(end_time - start_time );
2835
- if (funct -> runtime > funct -> maxtime ) {
2836
- funct -> maxtime = funct -> runtime ;
2847
+ * ( funct -> runtime ) = (hal_s32_t )(end_time - start_time );
2848
+ if ( * ( funct -> runtime ) > funct -> maxtime ) {
2849
+ funct -> maxtime = * ( funct -> runtime ) ;
2837
2850
funct -> maxtime_increased = 1 ;
2838
2851
} else {
2839
2852
funct -> maxtime_increased = 0 ;
@@ -3445,6 +3458,7 @@ static void free_funct_struct(hal_funct_t * funct)
3445
3458
funct -> users = 0 ;
3446
3459
funct -> arg = 0 ;
3447
3460
funct -> funct = 0 ;
3461
+ funct -> runtime = 0 ;
3448
3462
funct -> name [0 ] = '\0' ;
3449
3463
/* add it to free list */
3450
3464
funct -> next_ptr = hal_data -> funct_free_ptr ;
0 commit comments