58 lines
1.3 KiB
C
58 lines
1.3 KiB
C
#ifndef TASK01_SCHEDULER_MODEL_H
|
|
#define TASK01_SCHEDULER_MODEL_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
enum
|
|
{
|
|
SCHED_PEER_A = 0U,
|
|
SCHED_PEER_B = 1U,
|
|
SCHED_ORDER_BEFORE_RAISE = 1U,
|
|
SCHED_ORDER_HIGH_PROBE = 2U,
|
|
SCHED_ORDER_AFTER_RAISE = 3U
|
|
};
|
|
|
|
static inline int scheduler_trace_has_aba( const uint32_t * task_ids,
|
|
size_t count )
|
|
{
|
|
size_t index;
|
|
|
|
for( index = 2U; index < count; ++index )
|
|
{
|
|
if( task_ids[ index - 2U ] == SCHED_PEER_A &&
|
|
task_ids[ index - 1U ] == SCHED_PEER_B &&
|
|
task_ids[ index ] == SCHED_PEER_A )
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static inline int scheduler_ticks_nondecreasing( const uint32_t * ticks,
|
|
size_t count )
|
|
{
|
|
size_t index;
|
|
|
|
for( index = 1U; index < count; ++index )
|
|
{
|
|
if( ticks[ index ] < ticks[ index - 1U ] )
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static inline int scheduler_preemption_order_valid( const uint32_t * order,
|
|
size_t count )
|
|
{
|
|
return count == 3U &&
|
|
order[ 0 ] == SCHED_ORDER_BEFORE_RAISE &&
|
|
order[ 1 ] == SCHED_ORDER_HIGH_PROBE &&
|
|
order[ 2 ] == SCHED_ORDER_AFTER_RAISE;
|
|
}
|
|
|
|
#endif
|