[pok-devel] [44] correct timing of delayed start, previous method was wrong

[ Thread Index | Date Index | More lists.tuxfamily.org/pok-devel Archives ]


Revision: 44
Author:   jrosen
Date:     2013-01-25 13:28:02 +0100 (Fri, 25 Jan 2013)
Log Message:
-----------
correct timing of delayed start, previous method was wrong

Modified Paths:
--------------
    trunk/kernel/core/partition.c
    trunk/kernel/core/thread.c
    trunk/kernel/include/core/sched.h
    trunk/libpok/arinc653/queueing.c
    trunk/libpok/include/arinc653/queueing.h

Modified: trunk/kernel/core/partition.c
===================================================================
--- trunk/kernel/core/partition.c	2012-10-05 16:34:19 UTC (rev 43)
+++ trunk/kernel/core/partition.c	2013-01-25 12:28:02 UTC (rev 44)
@@ -276,21 +276,24 @@
 
 	 pok_thread_t* thread;
 	 unsigned int i;
-	 for (i = 0; i < pok_partitions[pok_current_partition].nthreads; i++)
+	 for (i = 0; i < pok_partitions[pid].nthreads; i++)
 	 {
 		 thread = &(pok_threads[POK_CURRENT_PARTITION.thread_index_low + i]);
 		 if ((long long)thread->period == -1) {//-1 <==> ARINC INFINITE_TIME_VALUE
-			 if(thread->state == POK_STATE_WAITING) { // delayed start, the delay is in the wakeup time
+			 if(thread->state == POK_STATE_DELAYED_START) { // delayed start, the delay is in the wakeup time
 				 if(!thread->wakeup_time) {
 					 thread->state = POK_STATE_RUNNABLE;
+				 } else {
+					 thread->state = POK_STATE_WAITING;
 				 }
 				 thread->wakeup_time += POK_GETTICK();
 				 thread->end_time =  thread->wakeup_time + thread->time_capacity;
 			 }
 		 } else {
-			 if(thread->state == POK_STATE_WAITING) { // delayed start, the delay is in the wakeup time
-				 thread->wakeup_time += POK_CONFIG_SCHEDULING_MAJOR_FRAME + POK_CURRENT_PARTITION.activation;
-				 thread->end_time =  thread->wakeup_time + thread->time_capacity;
+			 if(thread->state == POK_STATE_DELAYED_START) { // delayed start, the delay is in the wakeup time
+				 thread->next_activation = thread->wakeup_time + POK_CONFIG_SCHEDULING_MAJOR_FRAME + POK_CURRENT_PARTITION.activation;
+				 thread->end_time =  thread->next_activation + thread->time_capacity;
+				 thread->state = POK_STATE_WAIT_NEXT_ACTIVATION;
 			 }
 		 }
 	 }

Modified: trunk/kernel/core/thread.c
===================================================================
--- trunk/kernel/core/thread.c	2012-10-05 16:34:19 UTC (rev 43)
+++ trunk/kernel/core/thread.c	2013-01-25 12:28:02 UTC (rev 44)
@@ -321,14 +321,14 @@
   	  else
   	    {
   	      pok_threads[id].state = POK_STATE_WAITING;
-  	      pok_threads[id].wakeup_time = ms;
+  	      pok_threads[id].wakeup_time = POK_GETTICK() + ms;
   	    }
 	  //the preemption is always enabled so
   	  pok_sched();
   	}
       else //the partition mode is cold or warm start
   	{
-  	  pok_threads[id].state = POK_STATE_WAITING;
+  	  pok_threads[id].state = POK_STATE_DELAYED_START;
 	  pok_threads[id].wakeup_time = ms;
   	}
     }
@@ -341,8 +341,8 @@
 	    }
       else
 	   {
-	     pok_threads[id].state = POK_STATE_WAITING;
-	     pok_threads[id].wakeup_time = ms;
+	     pok_threads[id].state = POK_STATE_DELAYED_START;
+	     pok_threads[id].wakeup_time = ms; // temporarly storing the delay, see set_partition_mode
 	   }
     }
   return POK_ERRNO_OK;

Modified: trunk/kernel/include/core/sched.h
===================================================================
--- trunk/kernel/include/core/sched.h	2012-10-05 16:34:19 UTC (rev 43)
+++ trunk/kernel/include/core/sched.h	2013-01-25 12:28:02 UTC (rev 44)
@@ -38,7 +38,8 @@
   POK_STATE_RUNNABLE = 1,
   POK_STATE_WAITING = 2,
   POK_STATE_LOCK = 3,
-  POK_STATE_WAIT_NEXT_ACTIVATION = 4
+  POK_STATE_WAIT_NEXT_ACTIVATION = 4,
+  POK_STATE_DELAYED_START = 5
 } pok_state_t;
 
 void pok_sched_init (void); /* Initialize scheduling stuff */

Modified: trunk/libpok/arinc653/queueing.c
===================================================================
--- trunk/libpok/arinc653/queueing.c	2012-10-05 16:34:19 UTC (rev 43)
+++ trunk/libpok/arinc653/queueing.c	2013-01-25 12:28:02 UTC (rev 44)
@@ -98,6 +98,7 @@
 
    core_ret = pok_port_queueing_receive (QUEUING_PORT_ID, TIME_OUT, *LENGTH, MESSAGE_ADDR, (pok_port_size_t*)LENGTH);
 
+   if(core_ret == POK_ERRNO_EMPTY) core_ret = NOT_AVAILABLE;
    *return_code = core_ret;
 }
 
@@ -106,9 +107,10 @@
       /*out*/ QUEUING_PORT_ID_TYPE      *QUEUING_PORT_ID,
       /*out*/ RETURN_CODE_TYPE          *return_code)
 {
-   (void) QUEUING_PORT_NAME;
-   (void) QUEUING_PORT_ID;
-   *return_code = NOT_AVAILABLE;
+   pok_ret_t core_ret;
+
+   core_ret = pok_port_queueing_id(QUEUING_PORT_NAME, *QUEUING_PORT_ID);
+   *return_code = core_ret;
 }
 
 void GET_QUEUING_PORT_STATUS (
@@ -116,9 +118,25 @@
       /*out*/ QUEUING_PORT_STATUS_TYPE *QUEUING_PORT_STATUS,
       /*out*/ RETURN_CODE_TYPE          *return_code)
 {
-   (void) QUEUING_PORT_ID;
-   (void) QUEUING_PORT_STATUS;
-   *return_code = NOT_AVAILABLE;
+  pok_ret_t core_ret;
+  pok_port_queueing_status_t status;
+
+   core_ret = pok_port_queueing_id(QUEUING_PORT_ID, &status);
+   QUEUING_PORT_STATUS->NB_MESSAGE = status.nb_messages;
+#warning TBSL : commented to have it compile
+   //QUEUING_PORT_STATUS->MAX_NB_MESSAGE = status.g;
+   QUEUING_PORT_STATUS->MAX_MESSAGE_SIZE = status.size;
+   QUEUING_PORT_STATUS->PORT_DIRECTION = status.direction;
+   QUEUING_PORT_STATUS->WAITING_PROCESSES = status.waiting_processes;
+  *return_code = core_ret;
 }
 
+void CLEAR_QUEUING_PORT (
+      /*in */ QUEUING_PORT_ID_TYPE      QUEUING_PORT_ID,
+      /*out*/ RETURN_CODE_TYPE          *return_code)
+{
+  (void) QUEUING_PORT_ID;
+  *return_code = NOT_AVAILABLE;
+}
+
 #endif

Modified: trunk/libpok/include/arinc653/queueing.h
===================================================================
--- trunk/libpok/include/arinc653/queueing.h	2012-10-05 16:34:19 UTC (rev 43)
+++ trunk/libpok/include/arinc653/queueing.h	2013-01-25 12:28:02 UTC (rev 44)
@@ -69,6 +69,11 @@
       /*in */ QUEUING_PORT_ID_TYPE      QUEUING_PORT_ID,
       /*out*/ QUEUING_PORT_STATUS_TYPE *QUEUING_PORT_STATUS,
       /*out*/ RETURN_CODE_TYPE          *RETURN_CODE );
+
+extern void CLEAR_QUEUING_PORT (
+      /*in */ QUEUING_PORT_ID_TYPE      QUEUING_PORT_ID,
+      /*out*/ RETURN_CODE_TYPE          *RETURN_CODE );
+
 #endif
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/