⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thread.c

📁 基于ARM-LINXU的视频监控系统的编程.rar
💻 C
字号:
    #include <string.h>
    #include <sys/ioctl.h>
    #include <sys/mman.h>
    #include <sys/time.h>
    #include <sys/types.h>
    #include <sys/stat.h>

    #include <sys/types.h>
    #include <sys/ipc.h>
    #include <sys/sem.h>

    #include <time.h>
    #include <pthread.h>
    #include <sched.h>
    #include <termios.h>
    #include <unistd.h>
    #include <signal.h>
    #include "types.h"
    #include "thread.h"

    void CreateThreadEvent(PT_CONDSYNC *event, BOOL bManualReset)
    {
        if (event) {
            pthread_mutex_init (&event->mutex, NULL);
            pthread_cond_init  (&event->cond,  NULL);
        }
    }
	
    void DestroyThreadEvent(PT_CONDSYNC *event)
    {
        if (event) {
            pthread_mutex_destroy   (&event->mutex);
            pthread_cond_destroy    (&event->cond);
        }
    }

   void init_active_handle(HANDLE active_handle) {
        active_handle = INVALID_HANDLE_VALUE;
    }

   void start_thread(ThreadStruct thread_param, LPVOID app_param_struct, thread_function_fp thread_loop) 
    {
        pthread_attr_init(&thread_param.hThreadAttr);
        pthread_attr_setscope(&thread_param.hThreadAttr, PTHREAD_SCOPE_SYSTEM);
        pthread_create(&thread_param.hThread, &thread_param.hThreadAttr, thread_loop, app_param_struct);
    }

    void set_thread_priority(ThreadStruct thread_param, int nPriority) 
    {
        pthread_getschedparam(thread_param.hThread, &thread_param.policy, &thread_param.hThreadPrior);
        thread_param.policy = SCHED_RR;	// SCHED_FIFO is another option
        thread_param.hThreadPrior.sched_priority = nPriority;
        pthread_setschedparam(thread_param.hThread, thread_param.policy, &thread_param.hThreadPrior);
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -