module


Detailed Description

The tasklets module adds an interesting feature along the line, pioneered by RTAI, of a symmetric usage of all its services inter-intra kernel and user space, both for soft and hard real time applications.

In such a way you have opened a whole spectrum of development and implementation lanes, allowing maximum flexibility with uncompromized performances.

The new services provided can be useful when you have many tasks, both in kernel and user space, that must execute simple, often ripetitive, functions, both in soft and hard real time, asynchronously within their parent application. Such tasks are here called tasklets and can be of two kinds: normal tasklets and timed tasklets (timers).

It must be noted that only timers should need to be made available both in user and kernel space. In fact normal tasklets in kernel space are nothing but standard functions that can be directly executed by calling them, so there would be no need for any special treatment. However to maintain full usage symmetry and to ease any possible porting from one address space to the other, plain tasklets can be used in the same way from whatever address space.

Tasklets should be used where and whenever the standard hard real time RTAI tasks are used. Instances of such applications are timed polling and simple Programmable Logic Controllers (PLC) like sequences of services. Obviously there are many others instances that can make it sufficient the use of tasklets, either normal or timers. In general such an approach can be a very useful complement to fully featured tasks in controlling complex machines and systems, both for basic and support services.

It is remarked that the implementation found here for timed tasklets rely on server support tasks, one per cpu, that execute the related timer functions, either in oneshot or periodic mode, on the base of their time deadline and according to their, user assigned, priority. Instead, as told above, plain tasklets are just functions executed from kernel space; their execution needs no server and is simply triggered by calling a given service function at due time, either from a kernel task or interrupt handler requiring, or in charge of, their execution whenever they are needed.

Note that in user space you run within the memory of the process owning the tasklet function so you MUST lock all of your tasks memory in core, by using mlockall, to prevent it being swapped out. Pre grow also your stack to the largest size needed during the execution of your application, see mlockall usage in Linux mans.

The RTAI distribution contains many useful examples that demonstrate the use of most tasklets services, both in kernel and user space.


Files

file  rtai_nam2num.h
 Conversion between characters strings and unsigned long identifiers.
file  rtai_tasklets.h
 Interface of the mini LXRT RTAI tasklets module.
file  tasklets.c
 Implementation of the RTAI tasklets module.

Data Structures

struct  rt_usp_tasklet_struct
struct  support_tasklet_s
struct  rt_tasklets_struct
struct  ptimer_list

Defines

#define TASKLETS_IDX   1
#define INIT   0
#define DELETE   1
#define TASK_INSERT   2
#define TASK_REMOVE   3
#define USE_FPU   4
#define TIMER_INSERT   5
#define TIMER_REMOVE   6
#define SET_TASKLETS_PRI   7
#define SET_FIR_TIM   8
#define SET_PER   9
#define SET_HDL   10
#define SET_DAT   11
#define EXEC_TASKLET   12
#define WAIT_IS_HARD   13
#define SET_TSK_PRI   14
#define REG_TASK   15
#define GET_TMR_TIM   16
#define GET_TMR_OVRN   17
#define PTIMER_CREATE   18
#define PTIMER_SETTIME   19
#define PTIMER_OVERRUN   20
#define PTIMER_GETTIME   21
#define PTIMER_DELETE   22
#define POSIX_TIMERS   128
#define TASKLET_STACK_SIZE   8196
#define rt_tasklet_struct   rt_usp_tasklet_struct
#define rt_init_timer   rt_init_tasklet
#define rt_delete_timer   rt_delete_tasklet
#define rt_set_timer_handler   rt_set_tasklet_handler
#define rt_set_timer_data   rt_set_tasklet_data
#define rt_timer_use_fpu   rt_tasklet_use_fpu
#define rt_create_timers   rt_create_tasklets
#define rt_destroy_timers   rt_destroy_tasklets
#define rt_get_timer   rt_get_tasklet
#define rt_gvb_timer   rt_gvb_tasklet
#define NUM_CPUS   1
#define TIMED_TIMER_CPUID   (0)
#define TIMER_CPUID   (0)
#define LIST_CPUID   (0)
#define rb_erase_timer(timer)

Functions

static int support_tasklet (struct support_tasklet_s *args)
static void rt_delete_tasklet (struct rt_usp_tasklet_struct *tasklet)
static struct rt_usp_tasklet_structrt_init_tasklet (void)
 Init, in kernel space, a tasklet structure to be used in user space.
static int rt_insert_timer (struct rt_usp_tasklet_struct *timer, int priority, RTIME firing_time, RTIME period, void(*handler)(unsigned long), unsigned long data, int pid)
static void rt_remove_timer (struct rt_usp_tasklet_struct *timer)
static void rt_set_timer_priority (struct rt_usp_tasklet_struct *timer, int priority)
static void rt_set_timer_firing_time (struct rt_usp_tasklet_struct *timer, RTIME firing_time)
static void rt_set_timer_period (struct rt_usp_tasklet_struct *timer, RTIME period)
static void rt_get_timer_times (struct rt_usp_tasklet_struct *timer, RTIME timer_times[])
static RTIME rt_get_timer_overrun (struct rt_usp_tasklet_struct *timer)
static int rt_set_tasklet_handler (struct rt_usp_tasklet_struct *tasklet, void(*handler)(unsigned long))
static void rt_set_tasklet_data (struct rt_usp_tasklet_struct *tasklet, unsigned long data)
static RT_TASKrt_tasklet_use_fpu (struct rt_usp_tasklet_struct *tasklet, int use_fpu)
static int rt_insert_tasklet (struct rt_usp_tasklet_struct *tasklet, int priority, void(*handler)(unsigned long), unsigned long data, unsigned long id, int pid)
static void rt_set_tasklet_priority (struct rt_usp_tasklet_struct *tasklet, int priority)
static void rt_remove_tasklet (struct rt_usp_tasklet_struct *tasklet)
static int rt_exec_tasklet (struct rt_usp_tasklet_struct *tasklet)
static struct rt_tasklets_structrt_create_tasklets (int ntasklets)
static void rt_destroy_tasklets (struct rt_tasklets_struct *tasklets)
static struct rt_usp_tasklet_structrt_get_tasklet (struct rt_tasklets_struct *tasklets)
static int rt_gvb_tasklet (struct rt_usp_tasklet_struct *tasklet, struct rt_tasklets_struct *tasklets)
 MODULE_LICENSE ("GPL")
static struct rt_fun_entry
rt_tasklet_fun[] 
__attribute__ ((__unused__))
static void enq_timer (struct rt_tasklet_struct *timed_timer)
static void rem_timer (struct rt_tasklet_struct *timer)
RTAI_SYSCALL_MODE int rt_insert_tasklet (struct rt_tasklet_struct *tasklet, int priority, void(*handler)(unsigned long), unsigned long data, unsigned long id, int pid)
 Insert a tasklet in the list of tasklets to be processed.
RTAI_SYSCALL_MODE void rt_remove_tasklet (struct rt_tasklet_struct *tasklet)
 Remove a tasklet in the list of tasklets to be processed.
rt_tasklet_struct * rt_find_tasklet_by_id (unsigned long id)
 Find a tasklet identified by its id.
RTAI_SYSCALL_MODE int rt_exec_tasklet (struct rt_tasklet_struct *tasklet)
 Exec a tasklet.
RTAI_SYSCALL_MODE void rt_set_tasklet_priority (struct rt_tasklet_struct *tasklet, int priority)
RTAI_SYSCALL_MODE int rt_set_tasklet_handler (struct rt_tasklet_struct *tasklet, void(*handler)(unsigned long))
RTAI_SYSCALL_MODE void rt_set_tasklet_data (struct rt_tasklet_struct *tasklet, unsigned long data)
RTAI_SYSCALL_MODE RT_TASKrt_tasklet_use_fpu (struct rt_tasklet_struct *tasklet, int use_fpu)
static void asgn_min_prio (int cpuid)
static void set_timer_firing_time (struct rt_tasklet_struct *timer, RTIME firing_time)
RTAI_SYSCALL_MODE int rt_insert_timer (struct rt_tasklet_struct *timer, int priority, RTIME firing_time, RTIME period, void(*handler)(unsigned long), unsigned long data, int pid)
 Insert a timer in the list of timers to be processed.
RTAI_SYSCALL_MODE void rt_remove_timer (struct rt_tasklet_struct *timer)
 Remove a timer in the list of timers to be processed.
RTAI_SYSCALL_MODE void rt_set_timer_priority (struct rt_tasklet_struct *timer, int priority)
 Change the priority of an existing timer.
RTAI_SYSCALL_MODE void rt_set_timer_firing_time (struct rt_tasklet_struct *timer, RTIME firing_time)
 Change the firing time of a timer.
RTAI_SYSCALL_MODE void rt_set_timer_period (struct rt_tasklet_struct *timer, RTIME period)
 Change the period of a timer.
RTAI_SYSCALL_MODE void rt_get_timer_times (struct rt_tasklet_struct *timer, RTIME timer_times[])
RTAI_SYSCALL_MODE RTIME rt_get_timer_overrun (struct rt_tasklet_struct *timer)
 RTAI_MODULE_PARM (TimersManagerPrio, int)
static void rt_timers_manager (long cpuid)
RTAI_SYSCALL_MODE void rt_register_task (struct rt_tasklet_struct *tasklet, struct rt_tasklet_struct *usptasklet, RT_TASK *task)
RTAI_SYSCALL_MODE int rt_wait_tasklet_is_hard (struct rt_tasklet_struct *tasklet, long thread)
RTAI_SYSCALL_MODE int rt_delete_tasklet (struct rt_tasklet_struct *tasklet)
 Delete, in kernel space, a tasklet structure to be used in user space.
 RTAI_MODULE_PARM (PosixTimers, int)
static int init_ptimers (void)
static void cleanup_ptimers (void)
static int get_ptimer_indx (struct rt_tasklet_struct *timer)
static int gvb_ptimer_indx (int itimer)
RTAI_SYSCALL_MODE timer_t rt_ptimer_create (struct rt_tasklet_struct *timer, void(*handler)(unsigned long), unsigned long data, long pid, long thread)
 EXPORT_SYMBOL (rt_ptimer_create)
RTAI_SYSCALL_MODE void rt_ptimer_settime (timer_t timer, const struct itimerspec *value, unsigned long data, long flags)
 EXPORT_SYMBOL (rt_ptimer_settime)
RTAI_SYSCALL_MODE int rt_ptimer_overrun (timer_t timer)
 EXPORT_SYMBOL (rt_ptimer_overrun)
RTAI_SYSCALL_MODE void rt_ptimer_gettime (timer_t timer, RTIME timer_times[])
 EXPORT_SYMBOL (rt_ptimer_gettime)
RTAI_SYSCALL_MODE int rt_ptimer_delete (timer_t timer, long space)
 EXPORT_SYMBOL (rt_ptimer_delete)
 RTAI_MODULE_PARM (TaskletsStacksize, int)
int __rtai_tasklets_init (void)
void __rtai_tasklets_exit (void)

Variables

epoch_struct boot_epoch
static struct rt_tasklet_struct timers_list [NUM_CPUS]
static struct rt_tasklet_struct tasklets_list
static spinlock_t timers_lock [NUM_CPUS] = { SPIN_LOCK_UNLOCKED, }
static spinlock_t tasklets_lock = SPIN_LOCK_UNLOCKED
static struct rt_fun_entry rt_tasklet_fun []
static RT_TASK timers_manager [NUM_CPUS]
static int TimersManagerPrio = 0
static int PosixTimers = POSIX_TIMERS
static spinlock_t ptimer_lock = SPIN_LOCK_UNLOCKED
static volatile int ptimer_index
ptimer_listposix_timer
static int TaskletsStacksize = TASKLET_STACK_SIZE


Define Documentation

#define DELETE   1

Definition at line 39 of file rtai_tasklets.h.

Referenced by rt_delete_tasklet().

#define EXEC_TASKLET   12

Definition at line 50 of file rtai_tasklets.h.

Referenced by rt_exec_tasklet().

#define GET_TMR_OVRN   17

Definition at line 55 of file rtai_tasklets.h.

Referenced by rt_get_timer_overrun().

#define GET_TMR_TIM   16

Definition at line 54 of file rtai_tasklets.h.

Referenced by rt_get_timer_times().

#define INIT   0

Definition at line 38 of file rtai_tasklets.h.

Referenced by __wrap_timer_create(), and rt_init_tasklet().

#define LIST_CPUID   (0)

Definition at line 106 of file tasklets.c.

Referenced by asgn_min_prio(), rt_insert_timer(), and rt_timers_manager().

#define NUM_CPUS   1

Definition at line 103 of file tasklets.c.

Referenced by rt_insert_timer().

#define POSIX_TIMERS   128

Definition at line 65 of file rtai_tasklets.h.

#define PTIMER_CREATE   18

Definition at line 59 of file rtai_tasklets.h.

Referenced by __wrap_timer_create().

#define PTIMER_DELETE   22

Definition at line 63 of file rtai_tasklets.h.

Referenced by __wrap_timer_delete().

#define PTIMER_GETTIME   21

Definition at line 62 of file rtai_tasklets.h.

Referenced by __wrap_timer_gettime().

#define PTIMER_OVERRUN   20

Definition at line 61 of file rtai_tasklets.h.

Referenced by __wrap_timer_getoverrun().

#define PTIMER_SETTIME   19

Definition at line 60 of file rtai_tasklets.h.

Referenced by __wrap_timer_settime().

#define rb_erase_timer ( timer   ) 

Definition at line 198 of file tasklets.c.

Referenced by rem_timer().

#define REG_TASK   15

Definition at line 53 of file rtai_tasklets.h.

Referenced by support_posix_timer(), and support_tasklet().

#define rt_create_timers   rt_create_tasklets

Definition at line 545 of file rtai_tasklets.h.

#define rt_delete_timer   rt_delete_tasklet

Definition at line 403 of file rtai_tasklets.h.

#define rt_destroy_timers   rt_destroy_tasklets

Definition at line 557 of file rtai_tasklets.h.

#define rt_get_timer   rt_get_tasklet

Definition at line 578 of file rtai_tasklets.h.

#define rt_gvb_timer   rt_gvb_tasklet

Definition at line 596 of file rtai_tasklets.h.

#define rt_init_timer   rt_init_tasklet

Definition at line 392 of file rtai_tasklets.h.

#define rt_set_timer_data   rt_set_tasklet_data

Definition at line 471 of file rtai_tasklets.h.

#define rt_set_timer_handler   rt_set_tasklet_handler

Definition at line 463 of file rtai_tasklets.h.

#define rt_tasklet_struct   rt_usp_tasklet_struct

Definition at line 296 of file rtai_tasklets.h.

Referenced by __wrap_timer_create(), asgn_min_prio(), enq_timer(), rt_find_tasklet_by_id(), rt_ptimer_delete(), rt_ptimer_settime(), rt_timers_manager(), support_posix_timer(), and support_tasklet().

#define rt_timer_use_fpu   rt_tasklet_use_fpu

Definition at line 483 of file rtai_tasklets.h.

#define SET_DAT   11

Definition at line 49 of file rtai_tasklets.h.

Referenced by rt_set_tasklet_data().

#define SET_FIR_TIM   8

Definition at line 46 of file rtai_tasklets.h.

Referenced by rt_set_timer_firing_time().

#define SET_HDL   10

Definition at line 48 of file rtai_tasklets.h.

Referenced by rt_set_tasklet_handler().

#define SET_PER   9

Definition at line 47 of file rtai_tasklets.h.

Referenced by rt_set_timer_period().

#define SET_TASKLETS_PRI   7

Definition at line 45 of file rtai_tasklets.h.

Referenced by rt_set_timer_priority().

#define SET_TSK_PRI   14

Definition at line 52 of file rtai_tasklets.h.

Referenced by rt_set_tasklet_priority().

#define TASK_INSERT   2

Definition at line 40 of file rtai_tasklets.h.

Referenced by rt_insert_tasklet().

#define TASK_REMOVE   3

Definition at line 41 of file rtai_tasklets.h.

Referenced by rt_remove_tasklet().

#define TASKLET_STACK_SIZE   8196

Definition at line 71 of file rtai_tasklets.h.

Referenced by __wrap_timer_create(), rt_init_tasklet(), and support_tasklet().

#define TASKLETS_IDX   1

Definition at line 36 of file rtai_tasklets.h.

Referenced by __rtai_tasklets_exit(), __rtai_tasklets_init(), __wrap_timer_create(), __wrap_timer_delete(), __wrap_timer_getoverrun(), __wrap_timer_gettime(), __wrap_timer_settime(), rt_delete_tasklet(), rt_exec_tasklet(), rt_get_timer_overrun(), rt_get_timer_times(), rt_init_tasklet(), rt_insert_tasklet(), rt_insert_timer(), rt_remove_tasklet(), rt_remove_timer(), rt_set_tasklet_data(), rt_set_tasklet_handler(), rt_set_tasklet_priority(), rt_set_timer_firing_time(), rt_set_timer_period(), rt_set_timer_priority(), rt_tasklet_use_fpu(), support_posix_timer(), and support_tasklet().

#define TIMED_TIMER_CPUID   (0)

Definition at line 104 of file tasklets.c.

Referenced by enq_timer().

#define TIMER_CPUID   (0)

Definition at line 105 of file tasklets.c.

Referenced by rt_remove_timer(), rt_set_timer_firing_time(), rt_set_timer_period(), rt_set_timer_priority(), and set_timer_firing_time().

#define TIMER_INSERT   5

Definition at line 43 of file rtai_tasklets.h.

Referenced by rt_insert_timer().

#define TIMER_REMOVE   6

Definition at line 44 of file rtai_tasklets.h.

Referenced by rt_remove_timer().

#define USE_FPU   4

Definition at line 42 of file rtai_tasklets.h.

Referenced by rt_tasklet_use_fpu().

#define WAIT_IS_HARD   13

Definition at line 51 of file rtai_tasklets.h.

Referenced by rt_init_tasklet().


Function Documentation

static struct rt_fun_entry rt_tasklet_fun [] __attribute__ ( (__unused__)   )  [static]

void __rtai_tasklets_exit ( void   ) 

Definition at line 985 of file tasklets.c.

References cleanup_ptimers(), cpuid, printk(), reset_rt_fun_ext_index(), rt_task_delete, rt_tasklet_fun, TASKLETS_IDX, and timers_manager.

Here is the call graph for this function:

int __rtai_tasklets_init ( void   ) 

Definition at line 962 of file tasklets.c.

References cpuid, init_ptimers(), printk(), rt_task_init_cpuid(), rt_task_resume(), rt_tasklet_fun, rt_timers_manager(), set_rt_fun_ext_index(), TASKLETS_IDX, timers_list, timers_lock, and timers_manager.

Here is the call graph for this function:

static void asgn_min_prio ( int  cpuid  )  [inline, static]

Definition at line 388 of file tasklets.c.

References flags, LIST_CPUID, RT_SCHED_READY, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore, rt_tasklet_struct, timers_list, timers_lock, and timers_manager.

Referenced by rt_remove_timer(), rt_set_timer_priority(), and rt_timers_manager().

Here is the call graph for this function:

static void cleanup_ptimers ( void   )  [static]

Definition at line 844 of file tasklets.c.

References posix_timer.

Referenced by __rtai_tasklets_exit().

static void enq_timer ( struct rt_tasklet_struct *  timed_timer  )  [inline, static]

Definition at line 189 of file tasklets.c.

References rt_tasklet_struct, TIMED_TIMER_CPUID, and timers_list.

Referenced by rt_insert_timer(), rt_timers_manager(), and set_timer_firing_time().

EXPORT_SYMBOL ( rt_ptimer_delete   ) 

EXPORT_SYMBOL ( rt_ptimer_gettime   ) 

EXPORT_SYMBOL ( rt_ptimer_overrun   ) 

EXPORT_SYMBOL ( rt_ptimer_settime   ) 

EXPORT_SYMBOL ( rt_ptimer_create   ) 

static int get_ptimer_indx ( struct rt_tasklet_struct *  timer  )  [inline, static]

Definition at line 849 of file tasklets.c.

References flags, ptimer_list::p_ptr, posix_timer, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore, ptimer_list::t_indx, and ptimer_list::timer.

Referenced by rt_ptimer_create().

Here is the call graph for this function:

static int gvb_ptimer_indx ( int  itimer  )  [inline, static]

Definition at line 865 of file tasklets.c.

References flags, ptimer_list::p_idx, ptimer_list::p_ptr, posix_timer, rt_spin_lock_irqsave(), and rt_spin_unlock_irqrestore.

Referenced by rt_ptimer_delete().

Here is the call graph for this function:

static int init_ptimers ( void   )  [static]

Definition at line 828 of file tasklets.c.

References ptimer_list::p_ptr, posix_timer, PosixTimers, and printk().

Referenced by __rtai_tasklets_init().

Here is the call graph for this function:

MODULE_LICENSE ( "GPL"   ) 

static void rem_timer ( struct rt_tasklet_struct *  timer  )  [inline, static]

Definition at line 202 of file tasklets.c.

References rb_erase_timer.

Referenced by rt_remove_timer(), rt_timers_manager(), and set_timer_firing_time().

static struct rt_tasklets_struct* rt_create_tasklets ( int  ntasklets  )  [inline, static]

Definition at line 518 of file rtai_tasklets.h.

References rt_delete_tasklet(), rt_init_tasklet(), and rt_tasklets_struct::tasklets.

Here is the call graph for this function:

RTAI_SYSCALL_MODE int rt_delete_tasklet ( struct rt_tasklet_struct *  tasklet  ) 

Delete, in kernel space, a tasklet structure to be used in user space.

rt_tasklet_delete free a tasklet structure (struct rt_tasklet_struct) in kernel space that was allocated by rt_tasklet_init.

Parameters:
tasklet is the pointer to the tasklet structure (struct rt_tasklet_struct) returned by rt_tasklet_init.
This function is to be used only for user space tasklets. In kernel space it is just an empty macro, as the user can, and must allocate the related structure directly, either statically or dynamically.

Definition at line 803 of file tasklets.c.

References rt_free(), rt_remove_tasklet(), and rt_task_resume().

Here is the call graph for this function:

static void rt_delete_tasklet ( struct rt_usp_tasklet_struct tasklet  )  [inline, static]

Definition at line 394 of file rtai_tasklets.h.

References DELETE, rt_thread_join(), rtai_lxrt(), SIZARG, support_tasklet_s::tasklet, TASKLETS_IDX, and support_tasklet_s::thread.

Referenced by rt_create_tasklets(), rt_destroy_tasklets(), and rt_init_tasklet().

Here is the call graph for this function:

static void rt_destroy_tasklets ( struct rt_tasklets_struct tasklets  )  [inline, static]

Definition at line 547 of file rtai_tasklets.h.

References rt_delete_tasklet(), and rt_tasklets_struct::tasklets.

Here is the call graph for this function:

RTAI_SYSCALL_MODE int rt_exec_tasklet ( struct rt_tasklet_struct *  tasklet  ) 

Exec a tasklet.

rt_exec_tasklet execute a tasklet from the list of tasklets to be processed.

Parameters:
tasklet is the pointer to the tasklet structure to be used to manage the tasklet tasklet.
Kernel space tasklets addresses are usually available directly and can be easily be used in calling rt_tasklet_exec. In fact one can call the related handler directly without using such a support function, which is mainly supplied for symmetry and to ease the porting of applications from one space to the other.

User space tasklets instead must be first found within the tasklet list by calling rt_find_tasklet_by_id() to get the tasklet address to be used in rt_tasklet_exec().

Definition at line 339 of file tasklets.c.

References rt_task_resume().

Here is the call graph for this function:

static int rt_exec_tasklet ( struct rt_usp_tasklet_struct tasklet  )  [inline, static]

Definition at line 508 of file rtai_tasklets.h.

References EXEC_TASKLET, rtai_lxrt_t::i, rtai_lxrt(), SIZARG, and TASKLETS_IDX.

Here is the call graph for this function:

struct rt_tasklet_struct* rt_find_tasklet_by_id ( unsigned long  id  ) 

Find a tasklet identified by its id.

Parameters:
id is the unique unsigned long to be used to identify the tasklet.
The support functions nam2num() and num2nam() can be used for setting up id from a six character string.

Returns:
the pointer to a tasklet handler on success
Return values:
0 to indicate that id is not a valid identifier so that the related tasklet was not found.

Definition at line 306 of file tasklets.c.

References rt_tasklet_struct, and tasklets_list.

static struct rt_usp_tasklet_struct* rt_get_tasklet ( struct rt_tasklets_struct tasklets  )  [inline, static]

Definition at line 561 of file rtai_tasklets.h.

References atomic_cmpxchg(), rt_tasklets_struct::avb, rt_tasklets_struct::lock, rt_tasklets_struct::ntasklets, rt_tasklets_struct::out, and rt_tasklets_struct::tasklets.

Here is the call graph for this function:

RTAI_SYSCALL_MODE RTIME rt_get_timer_overrun ( struct rt_tasklet_struct *  timer  ) 

Definition at line 651 of file tasklets.c.

static RTIME rt_get_timer_overrun ( struct rt_usp_tasklet_struct timer  )  [inline, static]

Definition at line 451 of file rtai_tasklets.h.

References GET_TMR_OVRN, rtai_lxrt_t::rt, rtai_lxrt(), SIZARG, TASKLETS_IDX, and timer.

Referenced by rt_ptimer_overrun().

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_get_timer_times ( struct rt_tasklet_struct *  timer,
RTIME  timer_times[] 
)

Definition at line 640 of file tasklets.c.

References rt_get_time().

Here is the call graph for this function:

static void rt_get_timer_times ( struct rt_usp_tasklet_struct timer,
RTIME  timer_times[] 
) [inline, static]

Definition at line 441 of file rtai_tasklets.h.

References GET_TMR_TIM, rtai_lxrt(), SIZARG, TASKLETS_IDX, and timer.

Referenced by rt_ptimer_gettime().

Here is the call graph for this function:

static int rt_gvb_tasklet ( struct rt_usp_tasklet_struct tasklet,
struct rt_tasklets_struct tasklets 
) [inline, static]

Definition at line 580 of file rtai_tasklets.h.

References atomic_cmpxchg(), rt_tasklets_struct::avb, rt_tasklets_struct::in, rt_tasklets_struct::lock, rt_tasklets_struct::ntasklets, and rt_tasklets_struct::tasklets.

Here is the call graph for this function:

struct rt_tasklet_struct * rt_init_tasklet ( void   )  [inline, static]

Init, in kernel space, a tasklet structure to be used in user space.

rt_tasklet_init allocate a tasklet structure (struct rt_tasklet_struct) in kernel space to be used for the management of a user space tasklet.

This function is to be used only for user space tasklets. In kernel space it is just an empty macro, as the user can, and must allocate the related structure directly, either statically or dynamically.

Returns:
the pointer to the tasklet structure the user space application must use to access all its related services.

Definition at line 359 of file rtai_tasklets.h.

References support_tasklet_s::done, INIT, LOW, POLLS_PER_SEC, rt_delete_tasklet(), rt_is_hard_real_time(), rt_make_hard_real_time(), rt_make_soft_real_time(), rt_thread_create(), rtai_lxrt(), SIZARG, support_tasklet(), support_tasklet_s::tasklet, TASKLET_STACK_SIZE, TASKLETS_IDX, support_tasklet_s::thread, and WAIT_IS_HARD.

Referenced by rt_create_tasklets().

Here is the call graph for this function:

RTAI_SYSCALL_MODE int rt_insert_tasklet ( struct rt_tasklet_struct *  tasklet,
int  priority,
void(*)(unsigned long)  handler,
unsigned long  data,
unsigned long  id,
int  pid 
)

Insert a tasklet in the list of tasklets to be processed.

rt_insert_tasklet insert a tasklet in the list of tasklets to be processed.

Parameters:
tasklet is the pointer to the tasklet structure to be used to manage the tasklet at hand.
handler is the tasklet function to be executed.
data is an unsigned long to be passed to the handler. Clearly by an appropriate type casting one can pass a pointer to whatever data structure and type is needed.
id is a unique unsigned number to be used to identify the tasklet tasklet. It is typically required by the kernel space service, interrupt handler ot task, in charge of executing a user space tasklet. The support functions nam2num() and num2nam() can be used for setting up id from a six character string.
pid is an integer that marks a tasklet either as being a kernel or user space one. Despite its name you need not to know the pid of the tasklet parent process in user space. Simple use 0 for kernel space and 1 for user space.
Return values:
0 on success
Returns:
a negative number to indicate that an invalid handler address has been passed.

Definition at line 241 of file tasklets.c.

References flags, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore, tasklets_list, and tasklets_lock.

Here is the call graph for this function:

static int rt_insert_tasklet ( struct rt_usp_tasklet_struct tasklet,
int  priority,
void(*)(unsigned long)  handler,
unsigned long  data,
unsigned long  id,
int  pid 
) [inline, static]

Definition at line 490 of file rtai_tasklets.h.

References rtai_lxrt_t::i, rtai_lxrt(), SIZARG, TASK_INSERT, and TASKLETS_IDX.

Here is the call graph for this function:

RTAI_SYSCALL_MODE int rt_insert_timer ( struct rt_tasklet_struct *  timer,
int  priority,
RTIME  firing_time,
RTIME  period,
void(*)(unsigned long)  handler,
unsigned long  data,
int  pid 
)

Insert a timer in the list of timers to be processed.

rt_insert_timer insert a timer in the list of timers to be processed. Timers can be either periodic or oneshot. A periodic timer is reloaded at each expiration so that it executes with the assigned periodicity. A oneshot timer is fired just once and then removed from the timers list. Timers can be reinserted or modified within their handlers functions.

Parameters:
timer is the pointer to the timer structure to be used to manage the timer at hand.
priority is the priority to be used to execute timers handlers when more than one timer has to be fired at the same time.It can be assigned any value such that: 0 < priority < RT_LOWEST_PRIORITY.
firing_time is the time of the first timer expiration.
period is the period of a periodic timer. A periodic timer keeps calling its handler at firing_time + k*period k = 0, 1. To define a oneshot timer simply use a null period.
handler is the timer function to be executed at each timer expiration.
data is an unsigned long to be passed to the handler. Clearly by a appropriate type casting one can pass a pointer to whatever data structure and type is needed.
pid is an integer that marks a timer either as being a kernel or user space one. Despite its name you need not to know the pid of the timer parent process in user space. Simple use 0 for kernel space and 1 for user space.
Return values:
0 on success
EINVAL if handler is an invalid handler address

Definition at line 469 of file tasklets.c.

References cpuid, enq_timer(), flags, LIST_CPUID, NUM_CPUS, RT_SCHED_DELAYED, rt_schedule(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore, timers_list, timers_lock, and timers_manager.

Here is the call graph for this function:

static int rt_insert_timer ( struct rt_usp_tasklet_struct timer,
int  priority,
RTIME  firing_time,
RTIME  period,
void(*)(unsigned long)  handler,
unsigned long  data,
int  pid 
) [inline, static]

Definition at line 411 of file rtai_tasklets.h.

References rtai_lxrt_t::i, rtai_lxrt(), SIZARG, TASKLETS_IDX, timer, and TIMER_INSERT.

Referenced by rt_ptimer_settime().

Here is the call graph for this function:

RTAI_SYSCALL_MODE timer_t rt_ptimer_create ( struct rt_tasklet_struct *  timer,
void(*)(unsigned long)  handler,
unsigned long  data,
long  pid,
long  thread 
)

Definition at line 886 of file tasklets.c.

References get_ptimer_indx(), and rt_wait_tasklet_is_hard().

Here is the call graph for this function:

RTAI_SYSCALL_MODE int rt_ptimer_delete ( timer_t  timer,
long  space 
)

Definition at line 936 of file tasklets.c.

References gvb_ptimer_indx(), posix_timer, rt_free(), rt_remove_tasklet(), rt_task_resume(), rt_tasklet_struct, and ptimer_list::timer.

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_ptimer_gettime ( timer_t  timer,
RTIME  timer_times[] 
)

Definition at line 930 of file tasklets.c.

References posix_timer, and rt_get_timer_times().

Here is the call graph for this function:

RTAI_SYSCALL_MODE int rt_ptimer_overrun ( timer_t  timer  ) 

Definition at line 924 of file tasklets.c.

References posix_timer, and rt_get_timer_overrun().

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_ptimer_settime ( timer_t  timer,
const struct itimerspec *  value,
unsigned long  data,
long  flags 
)

Definition at line 899 of file tasklets.c.

References posix_timer, rt_get_time(), rt_insert_timer(), rt_remove_timer(), rt_tasklet_struct, ptimer_list::timer, and timespec2count().

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_register_task ( struct rt_tasklet_struct *  tasklet,
struct rt_tasklet_struct *  usptasklet,
RT_TASK task 
)

Definition at line 764 of file tasklets.c.

References task.

RTAI_SYSCALL_MODE void rt_remove_tasklet ( struct rt_tasklet_struct *  tasklet  ) 

Remove a tasklet in the list of tasklets to be processed.

rt_remove_tasklet remove a tasklet from the list of tasklets to be processed.

Parameters:
tasklet is the pointer to the tasklet structure to be used to manage the tasklet at hand.

Definition at line 280 of file tasklets.c.

References flags, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore, and tasklets_lock.

Here is the call graph for this function:

static void rt_remove_tasklet ( struct rt_usp_tasklet_struct tasklet  )  [inline, static]

Definition at line 502 of file rtai_tasklets.h.

References rtai_lxrt(), SIZARG, TASK_REMOVE, and TASKLETS_IDX.

Referenced by rt_delete_tasklet(), and rt_ptimer_delete().

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_remove_timer ( struct rt_tasklet_struct *  timer  ) 

Remove a timer in the list of timers to be processed.

rt_remove_timer remove a timer from the list of the timers to be processed.

Parameters:
timer is the pointer to the timer structure to be used to manage the timer at hand.

Definition at line 534 of file tasklets.c.

References asgn_min_prio(), flags, rem_timer(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore, TIMER_CPUID, and timers_lock.

Here is the call graph for this function:

static void rt_remove_timer ( struct rt_usp_tasklet_struct timer  )  [inline, static]

Definition at line 417 of file rtai_tasklets.h.

References rtai_lxrt(), SIZARG, TASKLETS_IDX, timer, and TIMER_REMOVE.

Referenced by rt_ptimer_settime().

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_set_tasklet_data ( struct rt_tasklet_struct *  tasklet,
unsigned long  data 
)

Definition at line 372 of file tasklets.c.

static void rt_set_tasklet_data ( struct rt_usp_tasklet_struct tasklet,
unsigned long  data 
) [inline, static]

Definition at line 465 of file rtai_tasklets.h.

References rtai_lxrt(), SET_DAT, SIZARG, and TASKLETS_IDX.

Here is the call graph for this function:

RTAI_SYSCALL_MODE int rt_set_tasklet_handler ( struct rt_tasklet_struct *  tasklet,
void(*)(unsigned long)  handler 
)

Definition at line 360 of file tasklets.c.

static int rt_set_tasklet_handler ( struct rt_usp_tasklet_struct tasklet,
void(*)(unsigned long)  handler 
) [inline, static]

Definition at line 457 of file rtai_tasklets.h.

References rtai_lxrt_t::i, rtai_lxrt(), SET_HDL, SIZARG, and TASKLETS_IDX.

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_set_tasklet_priority ( struct rt_tasklet_struct *  tasklet,
int  priority 
)

Definition at line 352 of file tasklets.c.

static void rt_set_tasklet_priority ( struct rt_usp_tasklet_struct tasklet,
int  priority 
) [inline, static]

Definition at line 496 of file rtai_tasklets.h.

References rtai_lxrt(), SET_TSK_PRI, SIZARG, and TASKLETS_IDX.

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_set_timer_firing_time ( struct rt_tasklet_struct *  timer,
RTIME  firing_time 
)

Change the firing time of a timer.

rt_set_timer_firing_time changes the firing time of a periodic timer overloading any existing value, so that the timer next shoot will take place at the new firing time. Note that if a oneshot timer has its firing time changed after it has already expired this function has no effect. You should reinsert it in the timer list with the new firing time.

Parameters:
timer is the pointer to the timer structure to be used to manage the timer at hand.
firing_time is the new time of the first timer expiration.
This function can be used within the timer handler.

Return values:
0 on success.

Definition at line 591 of file tasklets.c.

References flags, RT_SCHED_DELAYED, rt_schedule(), set_timer_firing_time(), TIMER_CPUID, timers_list, and timers_manager.

Here is the call graph for this function:

static void rt_set_timer_firing_time ( struct rt_usp_tasklet_struct timer,
RTIME  firing_time 
) [inline, static]

Definition at line 429 of file rtai_tasklets.h.

References rtai_lxrt(), SET_FIR_TIM, SIZARG, TASKLETS_IDX, and timer.

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_set_timer_period ( struct rt_tasklet_struct *  timer,
RTIME  period 
)

Change the period of a timer.

rt_set_timer_period changes the period of a periodic timer. Note that the new period will be used to pace the timer only after the expiration of the firing time already in place. Using this function with a period different from zero for a oneshot timer, that has not expired yet, will transform it into a periodic timer.

Parameters:
timer is the pointer to the timer structure to be used to manage the timer at hand.
period is the new period of a periodic timer.
The macro rt_fast_set_timer_period can substitute the corresponding function in kernel space if both the existing timer period and the new one fit into an 32 bits integer.

This function an be used within the timer handler.

Return values:
0 on success.

Definition at line 631 of file tasklets.c.

References flags, rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore, TIMER_CPUID, and timers_lock.

Here is the call graph for this function:

static void rt_set_timer_period ( struct rt_usp_tasklet_struct timer,
RTIME  period 
) [inline, static]

Definition at line 435 of file rtai_tasklets.h.

References rtai_lxrt(), SET_PER, SIZARG, TASKLETS_IDX, and timer.

Here is the call graph for this function:

RTAI_SYSCALL_MODE void rt_set_timer_priority ( struct rt_tasklet_struct *  timer,
int  priority 
)

Change the priority of an existing timer.

rt_set_timer_priority change the priority of an existing timer.

Parameters:
timer is the pointer to the timer structure to be used to manage the timer at hand.
priority is the priority to be used to execute timers handlers when more than one timer has to be fired at the same time. It can be assigned any value such that: 0 < priority < RT_LOWEST_PRIORITY.
This function can be used within the timer handler.

Definition at line 562 of file tasklets.c.

References asgn_min_prio(), and TIMER_CPUID.

Here is the call graph for this function:

static void rt_set_timer_priority ( struct rt_usp_tasklet_struct timer,
int  priority 
) [inline, static]

Definition at line 423 of file rtai_tasklets.h.

References rtai_lxrt(), SET_TASKLETS_PRI, SIZARG, TASKLETS_IDX, and timer.

Here is the call graph for this function:

RTAI_SYSCALL_MODE RT_TASK* rt_tasklet_use_fpu ( struct rt_tasklet_struct *  tasklet,
int  use_fpu 
)

Definition at line 380 of file tasklets.c.

static RT_TASK* rt_tasklet_use_fpu ( struct rt_usp_tasklet_struct tasklet,
int  use_fpu 
) [inline, static]

Definition at line 473 of file rtai_tasklets.h.

References rt_task_use_fpu(), rtai_lxrt(), SIZARG, task, TASKLETS_IDX, and USE_FPU.

Here is the call graph for this function:

static void rt_timers_manager ( long  cpuid  )  [static]

Definition at line 661 of file tasklets.c.

References asgn_min_prio(), enq_timer(), flags, linux_cr0, LIST_CPUID, rem_timer(), restore_fpcr, restore_fpenv, rt_get_time(), RT_SCHED_LOWEST_PRIORITY, rt_sleep_until(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore, rt_task_resume(), rt_tasklet_struct, save_fpcr_and_enable_fpu, save_fpenv, set_timer_firing_time(), timers_list, timers_lock, timers_manager, and tuned.

Referenced by __rtai_tasklets_init().

Here is the call graph for this function:

RTAI_SYSCALL_MODE int rt_wait_tasklet_is_hard ( struct rt_tasklet_struct *  tasklet,
long  thread 
)

Definition at line 771 of file tasklets.c.

References current, POLLS_PER_SEC, and RT_SCHED_SUSPENDED.

Referenced by rt_ptimer_create().

RTAI_MODULE_PARM ( TaskletsStacksize  ,
int   
)

RTAI_MODULE_PARM ( PosixTimers  ,
int   
)

RTAI_MODULE_PARM ( TimersManagerPrio  ,
int   
)

static void set_timer_firing_time ( struct rt_tasklet_struct *  timer,
RTIME  firing_time 
) [inline, static]

Definition at line 418 of file tasklets.c.

References enq_timer(), flags, rem_timer(), rt_spin_lock_irqsave(), rt_spin_unlock_irqrestore, TIMER_CPUID, and timers_lock.

Referenced by rt_set_timer_firing_time(), and rt_timers_manager().

Here is the call graph for this function:

static int support_tasklet ( struct support_tasklet_s args  )  [static]

Definition at line 320 of file rtai_tasklets.h.

References args, mlockall, REG_TASK, rt_grow_and_lock_stack, rt_make_hard_real_time(), rt_make_soft_real_time(), rt_task_delete, rt_task_suspend(), rt_tasklet_struct, rt_thread_init(), rtai_lxrt(), rtai_sti, task, TASKLET_STACK_SIZE, and TASKLETS_IDX.

Referenced by rt_init_tasklet().

Here is the call graph for this function:


Variable Documentation

struct epoch_struct boot_epoch

Definition at line 656 of file api.c.

struct ptimer_list * posix_timer

Referenced by cleanup_ptimers(), get_ptimer_indx(), gvb_ptimer_indx(), init_ptimers(), rt_ptimer_delete(), rt_ptimer_gettime(), rt_ptimer_overrun(), and rt_ptimer_settime().

int PosixTimers = POSIX_TIMERS [static]

Definition at line 821 of file tasklets.c.

Referenced by init_ptimers().

volatile int ptimer_index [static]

Definition at line 825 of file tasklets.c.

spinlock_t ptimer_lock = SPIN_LOCK_UNLOCKED [static]

Definition at line 824 of file tasklets.c.

struct rt_fun_entry rt_tasklet_fun[] [static]

Definition at line 125 of file tasklets.c.

Referenced by __rtai_tasklets_exit(), and __rtai_tasklets_init().

struct rt_tasklet_struct tasklets_list [static]

Initial value:

Definition at line 117 of file tasklets.c.

Referenced by rt_find_tasklet_by_id(), and rt_insert_tasklet().

spinlock_t tasklets_lock = SPIN_LOCK_UNLOCKED [static]

Definition at line 121 of file tasklets.c.

Referenced by rt_insert_tasklet(), and rt_remove_tasklet().

int TaskletsStacksize = TASKLET_STACK_SIZE [static]

Definition at line 959 of file tasklets.c.

struct rt_tasklet_struct timers_list[NUM_CPUS] [static]

Initial value:

{ { &timers_list[0], &timers_list[0], RT_SCHED_LOWEST_PRIORITY, 0, 0, RT_TIME_END, 0LL, NULL, 0UL, 0UL, 0, NULL, NULL, 0, 



}, }

Definition at line 110 of file tasklets.c.

Referenced by __rtai_tasklets_init(), asgn_min_prio(), enq_timer(), rt_insert_timer(), rt_set_timer_firing_time(), and rt_timers_manager().

spinlock_t timers_lock[NUM_CPUS] = { SPIN_LOCK_UNLOCKED, } [static]

Definition at line 120 of file tasklets.c.

Referenced by __rtai_tasklets_init(), asgn_min_prio(), rt_insert_timer(), rt_remove_timer(), rt_set_timer_period(), rt_timers_manager(), and set_timer_firing_time().

RT_TASK timers_manager[NUM_CPUS] [static]

Definition at line 386 of file tasklets.c.

Referenced by __rtai_tasklets_exit(), __rtai_tasklets_init(), asgn_min_prio(), rt_insert_timer(), rt_set_timer_firing_time(), and rt_timers_manager().

int TimersManagerPrio = 0 [static]

Definition at line 656 of file tasklets.c.


Generated on Tue Feb 2 17:48:47 2010 for RTAI API by  doxygen 1.4.7