39 #include "../ThreadInterface.hpp" 41 #include "../fosi_internal_interface.hpp" 42 #include "../../Logger.hpp" 62 DWORD dw = GetLastError();
65 FORMAT_MESSAGE_ALLOCATE_BUFFER |
66 FORMAT_MESSAGE_FROM_SYSTEM |
67 FORMAT_MESSAGE_IGNORE_INSERTS,
70 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
76 lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
77 (lstrlen((LPCTSTR) lpMsgBuf) + lstrlen((LPCTSTR) lpszFunction) + 40) *
sizeof(TCHAR));
83 MessageBox(NULL, (LPCTSTR) lpDisplayBuf, TEXT(
"Error"), MB_OK);
88 LocalFree(lpDisplayBuf);
93 void* (*realThread)(
void*);
102 void* (*realThread)(
void*) = threadWrapperData->
realThread;
103 void* realData = threadWrapperData->
realData;
104 delete threadWrapperData;
106 return (DWORD) realThread(realData);
113 const char* name =
"main";
115 main_task->
name = strcpy( (
char*)malloc( (strlen(name) + 1) *
sizeof(
char)), name);
116 main_task->
threadId = GetCurrentThreadId();
132 free(main_task->
name);
133 main_task->
name = NULL;
140 unsigned cpu_affinity,
144 void * (*start_routine)(
void *),
151 if (name == 0 || strlen(name) == 0)
153 task->
name = strncpy((
char*) malloc((strlen(name) + 1)
154 *
sizeof(
char)), name, strlen(name) + 1);
169 SetThreadPriority(task->
handle, priority);
181 DWORD
self = GetCurrentThreadId();
219 mytask->
period = nanosecs;
226 mytask->
period = nanosecs;
248 if ( timeRemaining > 0 ) {
269 WaitForSingleObject( mytask->
handle, INFINITE );
271 CloseHandle(mytask->
handle);
308 if (*priority <= -15){
309 log(
Warning) <<
"Forcing priority ("<<*priority<<
") of thread with !SCHED_OTHER policy to -15." <<
endlog();
314 log(
Warning) <<
"Forcing priority ("<<*priority<<
") of thread with !SCHED_OTHER policy to 15." <<
endlog();
325 SetThreadPriority(task->
handle, priority);
331 return GetThreadPriority(t->
handle);
354 return t->
name ? t->
name :
"(destroyed)";
int rtos_task_is_self(const RTOS_TASK *task)
DWORD WINAPI ThreadWrapper(void *threadData)
int rtos_task_get_priority(const RTOS_TASK *task)
INTERNAL_QUAL void rtos_task_make_periodic(RTOS_TASK *mytask, NANO_TIME nanosecs)
unsigned int rtos_task_get_pid(const RTOS_TASK *task)
NANO_TIME rtos_get_time_ns(void)
INTERNAL_QUAL int rtos_task_delete_main(RTOS_TASK *main_task)
int rtos_task_set_scheduler(RTOS_TASK *t, int sched_type)
static int rtos_nanosleep(const TIME_SPEC *rqtp, TIME_SPEC *rmtp)
int rtos_task_set_cpu_affinity(RTOS_TASK *task, unsigned cpu_affinity)
unsigned rtos_task_get_cpu_affinity(const RTOS_TASK *task)
INTERNAL_QUAL int rtos_task_check_priority(int *scheduler, int *priority)
void rtos_task_set_wait_period_policy(RTOS_TASK *task, int policy)
void rtos_task_delete(RTOS_TASK *mytask)
INTERNAL_QUAL void rtos_task_yield(RTOS_TASK *)
int rtos_task_set_priority(RTOS_TASK *task, int priority)
void *(* realThread)(void *)
const char * rtos_task_get_name(const RTOS_TASK *task)
void ErrorHandler(LPTSTR lpszFunction)
int rtos_task_check_scheduler(int *sched_type)
static TIME_SPEC ticks2timespec(TICK_TIME hrt)
int rtos_task_wait_period(RTOS_TASK *task)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
INTERNAL_QUAL int rtos_task_create_main(RTOS_TASK *main_task)
void rtos_task_set_period(RTOS_TASK *mytask, NANO_TIME nanosecs)
struct timespec TIME_SPEC
static Logger::LogFunction endlog()
INTERNAL_QUAL int rtos_task_create(RTOS_TASK *task, int priority, unsigned cpu_affinity, const char *name, int sched_type, size_t stack_size, void *(*start_routine)(void *), ThreadInterface *obj)
INTERNAL_QUAL NANO_TIME rtos_task_get_period(const RTOS_TASK *t)
int rtos_task_get_scheduler(const RTOS_TASK *t)