![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Linux c与c++开发
文章平均质量分 59
毕设
琉璃色的星辉
这个作者很懒,什么都没留下…
展开
-
Linux 利用POSIX多线程API函数进行线程同步
参考:《Linux c与c++一线开发实践》朱文伟 李建英将书上代码敲了一下,存在这里以便后续开发参考一、互斥锁定义互斥锁pthread_mutex_t mutex;互斥锁初始化(动态方式)int pthread_mutex_init(pthread_mutex_t *restrict mutex,const pthread_mutexattr_t *restrict attr);关键字restrict只用于限定指针,用于告知编译器所有修改该指针所指向的内容的操作全部都是基于该指针的,即不存在其原创 2021-03-21 21:10:12 · 198 阅读 · 0 评论 -
Linux C++11中线程类
参考:《Linux c与c++一线开发实践》朱文伟 李建英将书上代码敲了一下,存在这里以便后续开发参考一、类std::thread常用成员函数成员函数说明thread构造函数get_id获得线程IDjoinable判断线程对象是否可结束join阻塞函数,等待线程结束native_handle用于获得与操作系统相关的原生线程句柄swap线程交换detach分离线程二、线程的创建1.批量创建线程#include <std原创 2021-03-16 22:58:52 · 165 阅读 · 0 评论 -
Linux 利用POSIX多线程API函数进行多线程开发
与线程有关基本API函数API函数含义以上函数需要包含头文件pthread.h线程创建int pthread_create(pthread_t *pid, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)其中,pid是一个指针,指向创建成功后的线程ID;pthread_t其实就是unsigned long int;attr是指向线程属性结构原创 2021-03-15 21:42:03 · 257 阅读 · 0 评论 -
linux进程间通信 实例:使用kill发送信号终止目标进程
参考列表waitpid(…)函数:https://blog.csdn.net/yiyi__baby/article/details/45539993exit(…)函数:https://blog.csdn.net/u010006102/article/details/39737155代码参考:《Linux c与c++一线开发实践》朱文伟 李建英自学笔记c语言代码#include <sys/types.h>#include <sys/wait.h>#include <原创 2021-03-08 22:59:49 · 216 阅读 · 1 评论