"Open Macro Library"

Syntax quick tour

Timing Constraint Violation Exception (Deadline and WCET)

Macros for management of timing constraints violations for the C language, realised with an exception-handling paradigm. They allow for definition of time-scoped code regions, where the attempt of violation of the specified timing constraint leads to the automatic raise of an exception. Deadline constraints may be specified in terms of an absolute or relative deadline. WCET constraints may be defined in terms of maximum execution time the current thread is allowed to execute within the scoped region. Violation of the constraints leads to the throw of a EDeadlineException or EWCETViolation exception, respectively. These exceptions may be caught and dealt with similarly to how you deal with other exception types.
#include <oml_exceptions.h>
#include <stdio.h>
#include <time.h>

oml_define_exception(ENotReady) oml_extends(EException);

void too_long_func() {
  for (;;)
    ;
  oml_throw(ENotReady);
}

int main() {
  struct timespec dl, wcet;
  clock_gettime(CLOCK_MONOTONIC, &dl);
  dl.tv_sec += 2;
  printf("Starting deadline-bounded region for 2s\n");
  oml_try_within_abs(dl) {
    too_long_func();
  }
  oml_handle
    oml_when (EDeadlineViolation) {
      printf("Absolute DeadlineViolation caught !\n");
    }
    oml_when (ETimeConstrViolation) {
      printf("TimeConstrViolation caught !\n");
    }
    oml_when (EException) {
      printf("Exception caught !\n");
    }
  oml_end;

  wcet.tv_sec = 2;
  wcet.tv_nsec = 0;
  printf("Starting deadline-bounded region for 2s\n");
  oml_try_within_rel(wcet) {
    too_long_func();
  }
  oml_handle
    oml_when (EDeadlineViolation) {
      printf("Relative DeadlineViolation caught !\n");
    }
    oml_when (ETimeConstrViolation) {
      printf("TimeConstrViolation caught !\n");
    }
    oml_when (EException) {
      printf("Exception caught !\n");
    }
  oml_end;

  return 0;
}

Latest news

2009-01-25
Deadline exception

2009-01-24
Exceptions for C Package

2009-01-16
Exceptions for the C language

2007-03-06
Syntax quick tour update.





Last update:
March 2, 2010