05 2022 档案

摘要:## 编译时 gcc xx.c -o xx -pthread #include <stdio.h> #include <sys/types.h> #include <sys/ipc.h> #include <stdlib.h> #include <sys/msg.h> #include <strin 阅读全文
posted @ 2022-05-16 09:40 孤走 阅读(105) 评论(0) 推荐(0) 编辑
摘要:线程的互斥:使用线程互斥锁 初始化锁 #include <pthread.h> int pthread_mutex_init(pthread_mutex_t *restrict mutex,const pthread_mutexattr_t *restrict attr); 功能: 初始化互斥锁 参 阅读全文
posted @ 2022-05-15 20:39 孤走 阅读(19) 评论(0) 推荐(0) 编辑
摘要:线程的同步:用的是信号灯来实现 1. 线程信号灯的初始化 - include <semaphore.h> - sem_t sem; int sem_init(sem_t *sem, int pshared, unsigned int value); ****编译时后面如**gcc xx.c -o x 阅读全文
posted @ 2022-05-15 18:59 孤走 阅读(19) 评论(0) 推荐(0) 编辑
摘要:## 标题队列:先进先出 对数据进行分类(存储的时候分类) 操作: 1. 创建或者获取消息队列 1. 写入或者读取数据 2. 删除消息队列 ## 标题创建或者获取消息队列:#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>in 阅读全文
posted @ 2022-05-15 13:50 孤走 阅读(45) 评论(0) 推荐(0) 编辑
摘要:**tonly.c** ```c#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <fcntl. 阅读全文
posted @ 2022-05-14 20:11 孤走 阅读(31) 评论(0) 推荐(0) 编辑
摘要:xx.c ```c#include <stdio.h>#include <sys/types.h>#include <sys/ipc.h>#include <stdlib.h>#include <sys/shm.h>#include <unistd.h>#include <sys/sem.h>int 阅读全文
posted @ 2022-05-14 19:02 孤走 阅读(25) 评论(0) 推荐(0) 编辑
摘要:ls.c ```c#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#incl 阅读全文
posted @ 2022-05-14 15:46 孤走 阅读(12) 评论(0) 推荐(0) 编辑
摘要:点灯代码 本次代码基于野火的代码,使用STM32cubeMX生成,移植野火写的代码,也参考了小蜜蜂笔记(这是很好的入门) 下面是移植的代码 .c文件没有啥,主要是.h文件,一般都宏定义好的 这是.c文件 #include "bsp_led_HAL.h" /** * @brief 自由函数 * @pa 阅读全文
posted @ 2022-05-09 23:33 孤走 阅读(91) 评论(0) 推荐(0) 编辑
摘要:先了解下面的这几个结构体 以下三个函数可以获取文件/目录的属性信息:#include <unistd.h>#include <sys/types.h>#include <sys/stat.h> int stat(const char *path, struct stat *buf);//如果文件是符 阅读全文
posted @ 2022-05-07 19:20 孤走 阅读(457) 评论(0) 推荐(0) 编辑
摘要:第一方法: #include <time.h> time_t time(time_t *tloc); 功能:计算从1970年1月1日0时0分0秒 到 此时此刻的秒数 参数:保存秒数的变量地址在这里插入代码片 返回值:成功:返回获取的秒数 失败:-1 ctime() #include<stdio.h> 阅读全文
posted @ 2022-05-07 14:45 孤走 阅读(84) 评论(0) 推荐(0) 编辑