<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Task control (task.h)</title><link>https://sourceforge.net/p/deadlinertos/wiki/Task%2520control%2520%2528task.h%2529/</link><description>Recent changes to Task control (task.h)</description><atom:link href="https://sourceforge.net/p/deadlinertos/wiki/Task%20control%20(task.h)/feed" rel="self"/><language>en</language><lastBuildDate>Mon, 02 Dec 2013 12:48:35 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/deadlinertos/wiki/Task%20control%20(task.h)/feed" rel="self" type="application/rss+xml"/><item><title>Task control (task.h) modified by Stefan Gast</title><link>https://sourceforge.net/p/deadlinertos/wiki/Task%2520control%2520%2528task.h%2529/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v5
+++ v6
@@ -104,7 +104,7 @@
     :::c
     void vTaskDeadlineExtend(portTickType xTicksToAdd);

-TODO!
+Extends the current absolute deadline of the calling task until it gets recalculated again. If the task is currently running with an inherited deadline because it is holding a mutex, then the extended deadline will not be applied until the task is releasing the mutex. Extending the absolute deadline with this function has no effect on future deadline recalculation and can be thought of as a one-shot increase of the current absolute deadline. A future recalculation will use the original relative deadline again. **This function should not be used in combination with queues that were created with `eDeadlineRenewSent`. (TODO: Explain why!)**

 ---

@@ -120,7 +120,9 @@
     :::c
     portTickType xTaskDeadlineGetMinimumRemaining(xTaskHandle pxTask);

-TODO!
+Returns the minimum (over the whole lifetime of the task) amount of ticks a task had left before reaching its deadline. If the task reached or exceeded its deadline at some point, then the result is `0`.
+
+This functionality comes with a performance penalty, as the minimum time has to be updated each time a deadline gets recalculated, so it should only be used during application development. To activate it, the macro `INCLUDE_xTaskDeadlineGetMinimumRemaining` has to be defined as `1`.

 Removed functions
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefan Gast</dc:creator><pubDate>Mon, 02 Dec 2013 12:48:35 -0000</pubDate><guid>https://sourceforge.net758139ddeb1920b09ce9b4cd65e945910c7faec4</guid></item><item><title>Task control (task.h) modified by Stefan Gast</title><link>https://sourceforge.net/p/deadlinertos/wiki/Task%2520control%2520%2528task.h%2529/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -111,7 +111,9 @@
     :::c
     portTickType xTaskDeadlineGetRemaining(xTaskHandle pxTask);

-TODO!
+Returns the amount of ticks left until the given task reaches its absolute deadline. If `pxTask` is NULL, then the time remaining for the calling task is returned. If the task is blocked without an absolute deadline, then `portMAX_DELAY` is returned. If the task has reached or exceeded its deadline, then this function returns `0`.
+
+The macro `INCLUDE_xTaskDeadlineGetRemaining` has to be defined as `1` for this function to be available.

 ---

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefan Gast</dc:creator><pubDate>Tue, 26 Nov 2013 14:11:50 -0000</pubDate><guid>https://sourceforge.net7b84f5143a7ad4ece66a20da86c93a55a8dedbe0</guid></item><item><title>Task control (task.h) modified by Stefan Gast</title><link>https://sourceforge.net/p/deadlinertos/wiki/Task%2520control%2520%2528task.h%2529/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -102,7 +102,7 @@
 ---

     :::c
-    void vTaskDeadlineExtend(portTickType xTicksToAdd)
+    void vTaskDeadlineExtend(portTickType xTicksToAdd);

 TODO!

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefan Gast</dc:creator><pubDate>Fri, 22 Nov 2013 21:35:52 -0000</pubDate><guid>https://sourceforge.net3a7eb162ddb027f129498479e38c575b0dfc950c</guid></item><item><title>Task control (task.h) modified by Stefan Gast</title><link>https://sourceforge.net/p/deadlinertos/wiki/Task%2520control%2520%2528task.h%2529/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -71,6 +71,53 @@
 New functions and macros
 ------------------------

+    :::c
+    portTickType xTaskDelayUntilDeadline(void);
+
+This function blocks the calling task until its current absolute deadline is reached. After that, a new absolute deadline will be calculated, based on the configured relative deadline. If the current absolute deadline has already been reached or exceeded, then the macro `traceTASK_DELAY_UNTIL_DEADLINE_EXCEEDED` will be executed if defined. The function returns the number of ticks that the task had left until it would have reached the deadline. It is recommended to implement periodic tasks using this function,
+
+The macro `INCLUDE_xTaskDelayUntilDeadline` has to be defined as `1` for this function to be available.
+
+---
+
+    :::c
+    portTickType xTaskDeadlineGetNext(xTaskHandle pxTask);
+
+Returns the configured relative deadline for the given task. If `pxTask` is `NULL`, then the relative deadline of the calling task is returned.
+
+---
+
+    :::c
+    portTickType xTaskDeadlineSetNext(portTickType xNextDeadline);
+
+Sets the relative deadline of the calling task to the given amount of timer ticks. **The new value will not be used until a new absolute deadline is calculated for the task!** This function returns the previous setting for the relative deadline.
+
+---
+
+    :::c
+    #define taskNEW_DEADLINE    vTaskDelay((portTickType)0U, (signed portBASE_TYPE)pdTRUE)
+
+Force a recalculation of the absolute deadline of the calling task. The new absolute deadline will be the sum of the current time and the configured relative deadline.
+
+---
+
+    :::c
+    void vTaskDeadlineExtend(portTickType xTicksToAdd)
+
+TODO!
+
+---
+
+    :::c
+    portTickType xTaskDeadlineGetRemaining(xTaskHandle pxTask);
+
+TODO!
+
+---
+
+    :::c
+    portTickType xTaskDeadlineGetMinimumRemaining(xTaskHandle pxTask);
+
 TODO!

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefan Gast</dc:creator><pubDate>Fri, 22 Nov 2013 21:29:30 -0000</pubDate><guid>https://sourceforge.net05200777c3596bf2b01380c33ef70b07f991ae67</guid></item><item><title>Task control (task.h) modified by Stefan Gast</title><link>https://sourceforge.net/p/deadlinertos/wiki/Task%2520control%2520%2528task.h%2529/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -65,7 +65,7 @@
     :::c
     void vTaskList(signed char *pcWriteBuffer);

-Instead of writing the priority of each task the function now writes the absolute deadline of each task into the buffer. Please note that this requires a larger buffer: Currently each task requires 'configMAX_TASK_NAME_LEN + 52` bytes.
+Instead of writing the priority of each task the function now writes the absolute deadline of each task into the buffer. Please note that this requires a larger buffer: Currently each task requires `configMAX_TASK_NAME_LEN + 52` bytes.

 New functions and macros
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefan Gast</dc:creator><pubDate>Thu, 21 Nov 2013 20:52:48 -0000</pubDate><guid>https://sourceforge.net9a96f38a5554d5f9afddaf06242dbc47a8b54501</guid></item><item><title>Task control (task.h) modified by Stefan Gast</title><link>https://sourceforge.net/p/deadlinertos/wiki/Task%2520control%2520%2528task.h%2529/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="task-control-taskh"&gt;Task control (task.h)&lt;/h1&gt;
&lt;h2 id="modified-functions"&gt;Modified functions&lt;/h2&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="n"&gt;portBASE_TYPE&lt;/span&gt; &lt;span class="nf"&gt;xTaskCreate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdTASK_CODE&lt;/span&gt; &lt;span class="n"&gt;pvTaskCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;signed&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;pcName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;short&lt;/span&gt; &lt;span class="n"&gt;usStackDepth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;pvParameters&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;portTickType&lt;/span&gt; &lt;span class="n"&gt;xInitialDeadline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="n"&gt;portBASE_TYPE&lt;/span&gt; &lt;span class="n"&gt;uxFlags&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;xTaskHandle&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;pvCreatedTask&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Instead of expecting a priority value, the &lt;code&gt;xTaskCreate&lt;/code&gt; function now requires the initial relative deadline of the task in ticks (&lt;code&gt;xInitialDeadline&lt;/code&gt;). If the scheduler has already been started, the deadline runs from the time the task has been created, otherwise the deadline starts at the time the scheduler begins to run.&lt;/p&gt;
&lt;p&gt;The original FreeRTOS allows the &lt;code&gt;portPRIVILEGED_BIT&lt;/code&gt; to be ORed with the priority. Since we need each bit of the initial deadline, we cannot do this for the deadline parameter. Instead &lt;code&gt;uxFlags&lt;/code&gt; is used, which can either be &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;portPRIVILEGE_BIT&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;xTASK_PARAMETERS&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;pdTASK_CODE&lt;/span&gt; &lt;span class="n"&gt;pvTaskCode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;signed&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;pcName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;short&lt;/span&gt; &lt;span class="n"&gt;usStackDepth&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;pvParameters&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;portTickType&lt;/span&gt; &lt;span class="n"&gt;xInitialDeadline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="cm"&gt;/* &amp;lt;-- */&lt;/span&gt;
    &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="n"&gt;portBASE_TYPE&lt;/span&gt; &lt;span class="n"&gt;uxFlags&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="cm"&gt;/* &amp;lt;-- */&lt;/span&gt;
    &lt;span class="n"&gt;portSTACK_TYPE&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;puxStackBuffer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;xMemoryRegion&lt;/span&gt; &lt;span class="n"&gt;xRegions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;portNUM_CONFIGURABLE_REGIONS&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;xTaskParameters&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;portBASE_TYPE&lt;/span&gt; &lt;span class="nf"&gt;xTaskCreateRestricted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xTaskParameters&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;pxTaskParameters&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;xTaskHandle&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;pxCreatedTask&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The changes in the &lt;code&gt;xTaskParameters&lt;/code&gt; struct match those in the parameters of &lt;code&gt;xTaskCreate&lt;/code&gt;. For the starting time of initial deadline, the same applies as with &lt;code&gt;xTaskCreate&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;vTaskDelay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;portTickType&lt;/span&gt; &lt;span class="n"&gt;xTicksToDelay&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;signed&lt;/span&gt; &lt;span class="n"&gt;portBASE_TYPE&lt;/span&gt; &lt;span class="n"&gt;xRenewDeadline&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The new parameter &lt;code&gt;xRenewDeadline&lt;/code&gt; determines whether the absolute deadline of the calling should be removed during the delay and a new absolute deadline should be calculated after waiting. If this is set to &lt;code&gt;pdTRUE&lt;/code&gt;, then the new absolute deadline of the task will be the sum of the time the task was scheduled to wake up plus the relative deadline of the task. Otherwise the old absolute deadline will be kept.&lt;/p&gt;
&lt;hr /&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;vTaskDelayUntil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;portTickType&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;pxPreviousWakeTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;portTickType&lt;/span&gt; &lt;span class="n"&gt;xTimeIncrement&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This function has been modified to always recalculate the absolute deadline after blocking, in the same manner as &lt;code&gt;vTaskDelay&lt;/code&gt; does if &lt;code&gt;xRenewDeadline&lt;/code&gt; is &lt;code&gt;pdTRUE&lt;/code&gt;. If the function does not block because the desired wake up time has already been reached (or passed), then &lt;code&gt;xTaskDelayUntil&lt;/code&gt; executes the &lt;code&gt;traceTASK_DELAY_UNTIL_NONBLOCK&lt;/code&gt; macro and recalculates the new absolute deadline as the sum of the current time and the relative deadline of the task. If this happens, it usually means that the desired wake up frequency cannot be kept, so consider this to be a processing overflow!&lt;/p&gt;
&lt;hr /&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;vTaskSuspend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xTaskHandle&lt;/span&gt; &lt;span class="n"&gt;pxTaskToSleep&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If a task puts itself to sleep using &lt;code&gt;vTaskSuspend&lt;/code&gt;, then this is considered to be voluntarily and the absolute deadline of the task gets removed. A new absolute deadline will be calculated upon resuming of the task (via &lt;code&gt;vTaskResume&lt;/code&gt; or &lt;code&gt;xTaskResumeFromISR&lt;/code&gt;). If this function is used to suspend another task than the calling one, then the absolute deadline will remain active.&lt;/p&gt;
&lt;hr /&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;vTaskList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;signed&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;pcWriteBuffer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Instead of writing the priority of each task the function now writes the absolute deadline of each task into the buffer. Please note that this requires a larger buffer: Currently each task requires 'configMAX_TASK_NAME_LEN + 52` bytes.&lt;/p&gt;
&lt;h2 id="new-functions-and-macros"&gt;New functions and macros&lt;/h2&gt;
&lt;p&gt;TODO!&lt;/p&gt;
&lt;h2 id="removed-functions"&gt;Removed functions&lt;/h2&gt;
&lt;p&gt;In the original FreeRTOS API following functions are used to manage fixed priorities. They are not needed for EDF scheduling and thus they have been removed from deadlineRTOS:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="n"&gt;portBASE_TYPE&lt;/span&gt; &lt;span class="nf"&gt;uxTaskPriorityGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xTaskHandle&lt;/span&gt; &lt;span class="n"&gt;pxTask&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;vTaskPrioritySet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xTaskHandle&lt;/span&gt; &lt;span class="n"&gt;pxTask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="n"&gt;portBASE_TYPE&lt;/span&gt; &lt;span class="n"&gt;uxNewPriority&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stefan Gast</dc:creator><pubDate>Thu, 21 Nov 2013 20:32:25 -0000</pubDate><guid>https://sourceforge.netd3998f0a20027aefc404100246dc6aa502f86fd4</guid></item></channel></rss>