• PThread 学习笔记


    线程相关函数:

    1. pthread 相关函数的头文件: 

        #include <pthread.h>

    2. pthread 的创建函数:

        int pthread_create (pthread_t *thread_id, const pthread_attr_t *attributes, void *(*thread_function)(void *), void *arguments);

    3. pthread 对应的结束函数:

        int pthread_exit (void *status);

    4. 一个线程可以等待另一个线程的结束:

        int pthread_join (pthread_t thread, void **status_ptr);

    5. 获取当前线程的 id:

        pthread_t pthread_self ();

    6. 比较线程 id:

        int pthread (pthread_t t1, pthread_t t2);

    互斥量有两个基本操作:锁与解锁。有五个基本函数用来管理互斥量:

    1.  int pthread_mutex_init (pthread_mutex_t *mut, const pthread_mutexattr_t *attr);

    2. int pthread_mutex_lock (pthread_mutex_t *mut);

    3. int pthread_mutex_unlock (pthread_mutex_t *mut);

    4. int pthread_mutex_trylock (pthread_mutex_t *mut);

    5. int pthread_mutex_destroy (pthread_mutex_t *mut);

    条件变量

    1. int pthread_cond_init (pthread_cond_t *cond, pthread_condattr_t *attr);

    2. int pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mut);

    3. int pthread_cond_signal (pthread_cond_t *cond);

    4. int pthread_cond_broadcast (pthread_cond_t *cond);

    5. int pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mut, const struct timespec *abstime);

    6. int pthread_cond_destroy (pthread_cond_t *cond);

  • 相关阅读:
    mysql升级大致
    初始化配置文件的使用:/etc/my.cnf
    mysql用户管理
    MySql的逻辑结构(抽象结构)与物理结构
    5.7与5.6版本在部署方面的改变
    MySql服务器进程结构
    MySql服务器构成 --实列
    mysql客户端与服务器端模型
    RDBMS和NoSQL区别即主流sql
    MySql基本操作
  • 原文地址:https://www.cnblogs.com/Proteas/p/2348453.html
Copyright © 2020-2023  润新知