265
272
static int __task_delete(RT_TASK *rt_task)
267
274
struct task_struct *process;
276
if (current != rt_task->lnxtsk) {
279
if ((process = rt_task->lnxtsk)) {
280
process->rtai_tskext(TSKEXT0) = process->rtai_tskext(TSKEXT1) = 0;
282
if (rt_task->is_hard > 0) {
283
give_back_to_linux(rt_task, 0);
268
285
if (rt_task->linux_syscall_server) {
269
rt_task_masked_unblock(rt_task->linux_syscall_server->task, ~RT_SCHED_READY);
271
if (current == rt_task->lnxtsk && rt_task->is_hard > 0) {
272
give_back_to_linux(rt_task, 0);
286
RT_TASK *serv = rt_task->linux_syscall_server->serv;
287
serv->suspdepth = -RTE_HIGERR;
288
rt_task_masked_unblock(serv, ~RT_SCHED_READY);
289
process->state = TASK_INTERRUPTIBLE;
290
schedule_timeout(HZ/10);
274
293
if (clr_rtext(rt_task)) {
290
306
#define SYSW_DIAG_MSG(x)
293
#define recover_hardrt(chktsk, task) \
295
if ((chktsk) && unlikely(((task)->is_hard) < 0)) { \
296
SYSW_DIAG_MSG(rt_printk("GOING BACK TO HARD (SYSLXRT, DIRECT), PID = %d.\n", current->pid);); \
297
steal_from_linux(task); \
298
SYSW_DIAG_MSG(rt_printk("GONE BACK TO HARD (SYSLXRT), PID = %d.\n", current->pid);); \
309
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)
311
#include <linux/cred.h>
312
static inline void set_lxrt_perm(int perm)
315
if ((cred = prepare_creds())) {
316
cap_raise(cred->cap_effective, perm);
321
#else /* LINUX_VERSION_CODE <= 2.6.28 */
323
static inline void set_lxrt_perm(int perm)
326
cap_raise(current_cap(), perm);
328
cap_raise(current->cap_effective, perm);
332
#endif /* LINUX_VERSION_CODE > 2.6.28 */
334
void rt_make_hard_real_time(RT_TASK *task)
336
if (task && task->magic == RT_TASK_MAGIC && !task->is_hard) {
337
steal_from_linux(task);
341
void rt_make_soft_real_time(RT_TASK *task)
343
if (task && task->magic == RT_TASK_MAGIC && task->is_hard) {
344
if (task->is_hard > 0) {
345
give_back_to_linux(task, 0);
302
352
static inline long long handle_lxrt_request (unsigned int lxsrq, long *arg, RT_TASK *task)
316
366
* (giuseppe@renoldi.org).
318
368
if (unlikely(!(funcm = rt_fun_ext[INDX(lxsrq)]))) {
319
rt_printk("BAD: null rt_fun_ext[%d]\n", INDX(lxsrq));
369
rt_printk("BAD: null rt_fun_ext, no module for extension %d?\n", INDX(lxsrq));
322
372
if (!(type = funcm[srq].type)) {
323
recover_hardrt(task, task);
324
373
return ((RTAI_SYSCALL_MODE long long (*)(unsigned long, ...))funcm[srq].fun)(RTAI_FUN_ARGS);
326
recover_hardrt(1, task);
327
375
if (unlikely(NEED_TO_RW(type))) {
328
376
lxrt_fun_call_wbuf(task, funcm[srq].fun, NARG(lxsrq), arg, type);
596
static inline void force_soft(RT_TASK *task)
654
static inline void check_to_soften_harden(RT_TASK *task)
598
656
if (unlikely(task->force_soft)) {
599
task->force_soft = 0;
600
task->usp_flags &= ~FORCE_SOFT;
601
give_back_to_linux(task, 0);
605
#if 1 // restructured
607
static inline void rt_do_signal(struct pt_regs *regs, RT_TASK *task)
609
if (unlikely(task->unblocked)) {
610
657
if (task->is_hard > 0) {
611
give_back_to_linux(task, task->force_soft ? 0 : -1);
658
give_back_to_linux(task, 0);
613
#ifdef RTAI_DO_LINUX_SIGNAL
615
unsigned long saved_eax = regs->LINUX_SYSCALL_RETREG;
616
regs->LINUX_SYSCALL_RETREG = -ERESTARTSYS; // -EINTR;
618
regs->LINUX_SYSCALL_RETREG = saved_eax;
619
if (task->is_hard < 0) {
620
steal_from_linux(task);
624
662
task->unblocked = task->force_soft = 0;
625
663
task->usp_flags &= ~FORCE_SOFT;
631
long long rtai_lxrt_invoke (unsigned int lxsrq, void *arg, struct pt_regs *regs)
635
if (likely((task = current->rtai_tskext(TSKEXT0)) != NULL)) {
637
rt_do_signal(regs, task);
638
retval = handle_lxrt_request(lxsrq, arg, task);
639
rt_do_signal(regs, task);
642
return handle_lxrt_request(lxsrq, arg, task);
646
#else // end restructured, begin old
648
static inline int rt_do_signal(struct pt_regs *regs, RT_TASK *task)
650
if (unlikely(task->unblocked)) {
651
int retval = task->unblocked < 0;
664
} else if (unlikely(task->is_hard < 0)) {
665
SYSW_DIAG_MSG(rt_printk("GOING BACK TO HARD (SYSLXRT, DIRECT), PID = %d.\n", current->pid););
666
steal_from_linux(task);
667
SYSW_DIAG_MSG(rt_printk("GONE BACK TO HARD (SYSLXRT), PID = %d.\n", current->pid););
668
} else if (unlikely(task->unblocked)) {
652
669
if (task->is_hard > 0) {
653
670
give_back_to_linux(task, -1);
655
#ifdef RTAI_DO_LINUX_SIGNAL
656
if (task->unblocked > 0) {
657
if (likely(regs->LINUX_SYSCALL_NR < RTAI_SYSCALL_NR)) {
658
unsigned long saved_eax = regs->LINUX_SYSCALL_RETREG;
659
regs->LINUX_SYSCALL_RETREG = -EINTR;
660
// regs->LINUX_SYSCALL_RETREG = -ERESTARTSYS;
662
regs->LINUX_SYSCALL_RETREG = saved_eax;
663
if (task->is_hard < 0) {
664
steal_from_linux(task);
669
672
task->unblocked = 0;
675
long long rtai_lxrt_invoke (unsigned int lxsrq, void *arg, struct pt_regs *regs)
676
long long rtai_lxrt_invoke (unsigned int lxsrq, void *arg)
679
680
if (likely((task = current->rtai_tskext(TSKEXT0)) != NULL)) {
680
681
long long retval;
681
if (unlikely(rt_do_signal(regs, task))) {
682
check_to_soften_harden(task);
684
683
retval = handle_lxrt_request(lxsrq, arg, task);
685
if (unlikely(rt_do_signal(regs, task))) {
684
check_to_soften_harden(task);
690
return handle_lxrt_request(lxsrq, arg, task);
688
return handle_lxrt_request(lxsrq, arg, NULL);
694
#endif // end olf part of restructured
696
691
int set_rt_fun_ext_index(struct rt_fun_entry *fun, int idx)
698
693
if (idx > 0 && idx < MAX_FUN_EXT && !rt_fun_ext[idx]) {