[NO REPLY] Critical Sections (rev #2, 2018-1-15)

Obsolete material.
User avatar
Giovanni
Site Admin
Posts: 12296
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 590 times
Been thanked: 504 times
Contact:

[NO REPLY] Critical Sections (rev #2, 2018-1-15)

Postby Giovanni » Sun Dec 10, 2017 7:54 pm

In order to address the problem posed by asynchronous events, ISRs in this example, an ad-hoc compound statement can be used:

Example:

Code: Select all

worddef exclusive async <isr> critical {
enter:
  Disable_IRQ();
leave:
  enable_IRQ();
async_enter:
  disable_IRQ_fromISR();
async_leave:
  enable_IRQ_fromISR();
}

critical int i = 0;

critical void signal(void) {
  ...
}

async <isr> void my_isr_function(void) {
  critical {
    i++;
    signal();
  }
}

void signal_handler(void) {
  int local_i;

  critical {
   local_i = i--;
  }
  use(local_i);
}


Critical functions

  • Functions that can only be called from within a critical section.
  • Critical functions can only call critical or pure/const functions.

Critical variables

  • Critical variables can only be accessed from within a critical block or by critical functions.

Giovanni

Return to “obsolete”

Who is online

Users browsing this forum: No registered users and 1 guest