Task Scheduler  f3c51100
internal_structures.h
1 /*
2  * Task scheduler for uniform task processing in user space.
3  * Copyright (C) 2015 Valdemar Lindberg
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 #ifndef _TASK_SCH_INTERNAL_STRUCTURES_H_
20 #define _TASK_SCH_INTERNAL_STRUCTURES_H_ 1
21 #include "../taskSch.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 
28 
33 typedef struct sch_task_pool_t {
34 
38  schThread *thread;
43  schThread *schRefThread;
44 
45  /* Thread race condition variables. */
46  void *mutex; /* Mutex. */ // TODO remove.
47  void *set; /* Thread signal. */
48 
49  /* Task Queue. */ // TODO consider using linked list for adding support for task migration.
50  // TODO add atomic for queue strucuture if posssible and faster than spinlock..
51  unsigned int size; /* Size of number of elements. */
52  unsigned int tail; /* End of the queue. */
53  unsigned int head; /* Start of the queue. */
54  unsigned int reserved; /* Number of allocate task packages. */
55  schTaskPackage *package; /* */
56 
57  /* User and init and release functions callbacks. */
58  void *userdata; /* User data. */
59  schUserCallBack init; /* Init user callback function. */
60  schUserCallBack deinit; /* DeInit user callback function. */
61 
62  /* Statistics for handling next task to execute. */
63  int avergeDeque; /* Average package dequeue per time unit. */
64  long int dheapPriority; /* */
65 
66  /* State and scheduler. */
67  void *sch; /* Scheduler associated with. */
68  unsigned int index; /* Affinity index. */
69  atomic_uint flag; /* Pool status flag. */
70 } schTaskPool;
71 
75 typedef struct sch_task_scheduler_t {
80  size_t num; /* Number of pools. */
85  schTaskPool *pool; /* Pools. */
90  atomic_uint flag; /* State/Status Flags. */
95  schTaskPool **dheap; /* Priority queue. */
100  schSpinLock *spinlock; /* Spin lock. */
105  schMutex *mutex;
110  schConditional *conditional;
115  schBarrier *barrier;
120  schSignalSet *set; /* Signal listening mask. */
121 } schTaskSch;
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 #endif
TaskPool.
Definition: internal_structures.h:33
schThread * schRefThread
Definition: internal_structures.h:43
schThread * thread
Definition: internal_structures.h:38
Task scheduler main struct container.
Definition: internal_structures.h:75
Definition: taskSch.h:188