Gatekeeper multicast task synchronization

I am working on a design that uses the gatekeeper task to access a shared resource. The main project that I have now is one turn from which the gatekeeper task receives, and several tasks that insert requests into it.

This is a limited memory system, and I use FreeRTOS (Cortex M3 port).

The problem is this: handling these requests asynchronously is quite simple. The requesting task queues its request and is engaged in its business, polling, processing or waiting for other events. To handle these requests synchronously, I need a mechanism for the requesting task to block so that after the request has been processed, the gatekeeper can wake up the task that caused this request.

The simplest project I can imagine is to include a semaphore in each request, but given the memory limitations and the rather large semaphore size in FreeRTOS, this is not practical.

What I came up with is to use the task pause function and the task resume function to manually block the task by passing a handle to the gatekeeper with which it can resume the task when the request is completed. However, there are some problems with the suspension / resumption, and I would really like to avoid them. One repeated call will cause the task no matter how many times it has been suspended by other calls, and this can lead to undesirable behavior.

Some simple pseudo-Cs to demonstrate the suspend / resume method.

void gatekeeper_blocking_request(void)
{
     put_request_in_queue(request);
     task_suspend(this_task);
}

void gatekeeper_request_complete_callback(request)
{
     task_resume(request->task);
}

, , - . - . , .

Pseudo-C, , .

void requesting_task(void)
{
     while(1)
     {
         gatekeeper_async_request(callback);
         pend_on_sempahore(sem);
     }
}

void callback(request)
{
     post_to_semaphore(sem);
}

, gatekeeper API . , , , . .

- , , , Google? .

. :

  • . , , .

  • . , .

+5
2

.

+1

, , , , . . , , , . FreeRTOS , , , .

:

void gatekeeper_blocking_request(void)
{
     put_request_in_queue(request);
     task_suspend(this_task);
}

void gatekeeper_request_complete_callback(request)
{
     task_resume(request->task);
}

, , , FreeRTOS suspend/resume , . / , .

FreeRTOS 8.2.0, Direct-to-task . , . , - xTaskNotifyWait(), , .

:

 void gatekeeper_blocking_request(void)
 {
      put_request_in_queue(request);
      xTaskNotifyWait( ... );
 }

 void gatekeeper_request_complete_callback(request)
 {
      xTaskNotify( ... );
 }

, - , suspend/resume, , , . , , .

0

All Articles