鲲鹏社区首页
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

HTL_thread_create

创建线程。

接口定义

int HTL_thread_create(HTL_thread_t *thread, const HTL_thread_attr_t *thread_attr, void *(*thread_func)(void *), void *thread_args);

描述

HTL_thread_create()创建一个用户级线程ULT,并通过thread返回其句柄。HTL会自动将创建的ULT与一个线程池绑定,thread必须由HTL_thread_free()显式释放。

该函数仅适用于HTL-PThreads并行编程模式。

参数

参数名

类型

描述

输入/输出

thread

HTL_thread_t *

ULT句柄。

输出

thread_attr

HTL_thread_attr_t *

ULT的属性。

输入

thread_func

void* (*thread_func)(void *)

新的ULT执行的函数。

输入

thread_args

void *

thread_func的入参。

输入

返回值

  • HTL_THREAD_SUCCESS:成功。
  • 其他:失败。见错误码定义。

示例

    /* Create Thread */
    for (i = 0; i < num_threads; i++) {
        arg[i] = i;
        ret = HTL_thread_create(&threads[i], NULL, thread_create, &arg[i]);
    }