I will soon start banging my head on the wall:
It is very simple, I want to measure the time during which the task takes 2 points (in Linux - 1 core - 1 processor). During this time, the task should have full control over the CPU and should NOT be interrupted by any other task or HW interruptions.
To achieve this, I created a kernel module to ensure that the above criteria are met. In this kernel module, I tried:
First disable IRQ:
- I used spin_lock_irqsave () / spin_lock_irqrestore () - I suppose this is the right way to make sure that all local interrupts are disabled and my task has a processor for it in the critical area.
Then
- Preempt_disable () is used → Since current = my task, the kernel should continue to execute my task logically until I turn on preemption → Does not work (my_task-> nvcsw and my_task-> nivcsw show that csw has happened → my task was unloaded)
I tried to increase the priority of my task by changing my_task-> prio and my_task-> static_prio to 1 → the highest real-time priority (my_task-> policy = SCHED_FIFO) ...
Doesn't work (my_task-> nvcsw and my_task-> nivcsw show that csw happened → my-task got preempted), and my_task-> prio got a new prio (120) scheduler, which I assume ...
- , / Linux? ( 50-500us) ?
/ (, , / procfs ):
switch( enable ){
case COS_OS_DISABLE:
preempt_disable()
last_policy = pTask->policy;
last_prio = pTask->prio;
last_static_prio = pTask->static_prio;
last_normal_prio = pTask->normal_prio;
last_rt_priority = pTask->rt_priority;
pTask->prio = 1;
pTask->static_prio = 1;
pTask->normal_prio = 1;
pTask->rt_priority = 1;
pTask->policy = SCHED_FIFO;
spin_lock_irqsave( &mr_lock , flags );
break;
case COS_OS_ENABLE:
default:
pTask->prio = last_prio;
pTask->static_prio = last_static_prio;
pTask->normal_prio = last_normal_prio;
pTask->rt_priority = last_rt_priority;
pTask->policy = last_policy;
spin_unlock_irqrestore( &mr_lock , flags );
preempt_enable();
break;
}