Header Ads

Scheduling Mechanisms in OSEK/AUTOSAR OS

In OSEK OS and AUTOSAR OS (which is based on the OSEK/VDX operating system specification), the scheduler is priority-based and preemptive by default, with support for non-preemptive and mixed-preemptive scheduling depending on task configuration.

Scheduling Mechanisms in OSEK/AUTOSAR OS

1. Fixed Priority Preemptive Scheduling (Most Common)

  • Every task is assigned a static priority at configuration time.
  • The highest-priority READY task is always selected to run.
  • If a higher-priority task becomes ready (for example, due to an interrupt or an event), it immediately preempts the currently running lower-priority task.

Example:

TaskPriority
Task A1
Task B3
Task C5

Execution:

Time →

Task A running
      |
      | Task C becomes READY
      V
Task C preempts Task A
      |
Task C finishes
      |
Task A resumes

This scheduling mechanism is widely used in automotive real-time systems because critical tasks (e.g., braking or airbag control) always execute first.


2. Non-Preemptive Scheduling

  • Once a task starts executing, it continues until:
    • it terminates,
    • calls Schedule(), or
    • waits for an event (extended task).
  • Higher-priority tasks must wait until the running task yields the CPU.

Example:

Task A running
Task C becomes READY
Task A continues
Task A terminates
Task C starts

This reduces context-switch overhead but increases response time for high-priority tasks.


3. Mixed Preemptive Scheduling

OSEK/AUTOSAR allows both:

  • Preemptive tasks
  • Non-preemptive tasks

to coexist in the same system.

For example:

Task A → Non-preemptive
Task B → Preemptive
Task C → Preemptive

This lets developers protect critical code sections without excessive locking.


Scheduling Types of Tasks

Basic Tasks

  • Do not wait for events.
  • Run until they terminate.
  • Suitable for periodic activities.

Extended Tasks

  • Can wait for events using WaitEvent().
  • Resume when the required event is set.
  • Commonly used for event-driven communication.

Scheduling Points

The scheduler is invoked at specific points, such as:

  • ActivateTask()
  • TerminateTask()
  • ChainTask()
  • Schedule()
  • SetEvent()
  • ISR completion (if a higher-priority task becomes ready)

Ready Queue

OSEK/AUTOSAR OS maintains READY queues based on priorities.

Priority 5 : Task C
Priority 4 :
Priority 3 : Task B
Priority 2 :
Priority 1 : Task A

The scheduler always selects the highest-priority READY task.


Resource Handling

To prevent priority inversion, OSEK/AUTOSAR uses the Priority Ceiling Protocol (PCP).

Example:

Task A (Priority 1)
        |
        | locks Resource R
        |
Priority temporarily raised
        |
Task C (Priority 5) cannot interrupt while Resource R is held

This ensures predictable execution and avoids unbounded blocking.


Scheduling in AUTOSAR OS

AUTOSAR OS inherits the OSEK scheduling model and adds configuration through AUTOSAR tools (e.g., DaVinci Configurator, EB tresos). Scheduling is still:

  • Static priority-based
  • Deterministic
  • Real-time
  • Configured at design time

The OS itself does not implement dynamic scheduling algorithms like Earliest Deadline First (EDF).


OSEK/AUTOSAR vs Other Scheduling Algorithms

Scheduling AlgorithmOSEK/AUTOSAR OSCharacteristics
Fixed Priority Preemptive (FPPS)✅ Primary mechanismStatic priorities, deterministic, real-time
Non-Preemptive✅ SupportedTasks run until they yield or terminate
Mixed Preemptive✅ SupportedCombination of preemptive and non-preemptive tasks
Round Robin⚠️ Optional for equal-priority tasks (implementation/configuration dependent)Time-sliced execution among tasks of the same priority
Earliest Deadline First (EDF)❌ Not part of the OSEK/AUTOSAR standardDynamic priority scheduling
Rate Monotonic Scheduling (RMS)❌ Not implemented as an OS schedulerCan be achieved by assigning fixed priorities according to task periods

Interview Answer (Short)

OSEK/AUTOSAR OS primarily uses a fixed-priority preemptive scheduling mechanism. Tasks are assigned static priorities at configuration time, and the highest-priority READY task always executes. The OS also supports non-preemptive and mixed-preemptive task scheduling, uses priority-based ready queues, and employs the Priority Ceiling Protocol to avoid priority inversion.