上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 46 下一页

2020年2月10日

c 共享内存demo

摘要: 一个进程写数据,一个进程读数据 写进程: 1. shmget()获取共享内存 2. shmat()共享内存映射到进程空间 3. 写数据 读进程: 1. shmget()获取共享内存 2. shmat()共享内存映射到进程空间 3. 读数据 4. shmdt()共享内存从进程空间解除映射 5. shm 阅读全文

posted @ 2020-02-10 16:43 luckygxf 阅读(951) 评论(0) 推荐(0) 编辑

2020年2月9日

c 消费者生产者V2

摘要: 增加了buffsize,生产者生产过多,wait #include <stdio.h> #include <unistd.h> #include <pthread.h> #define PRODUCER_SIZE 1 #define CONSUMER_SIZE 1 int products = 0; 阅读全文

posted @ 2020-02-09 14:48 luckygxf 阅读(162) 评论(0) 推荐(0) 编辑

c 生产者消费者V1

摘要: 1. 生产者1个线程 2. 消费者1个线程 3. 通过pthread_mutex_t并发控制 4. 通过pthread_cond_t wait signal 5. signal放到unlock后面 6. sleep放到unlock后面 #include <stdio.h> #include <uni 阅读全文

posted @ 2020-02-09 14:38 luckygxf 阅读(355) 评论(0) 推荐(0) 编辑

c多进程

摘要: 1. fork创建子进程 2. wait等待子进程结束 #include <stdio.h> #include <unistd.h> #include <sys/wait.h> int main() { int count = 0; int pid = fork(); if (pid == 0) { 阅读全文

posted @ 2020-02-09 11:40 luckygxf 阅读(343) 评论(0) 推荐(0) 编辑

c读写文件

摘要: #include <stdio.h> #include <unistd.h> #include <pthread.h> #include <stdlib.h> #include <string.h> char *fileName = "/Users/gxf/CLionProjects/untitle 阅读全文

posted @ 2020-02-09 11:27 luckygxf 阅读(138) 评论(0) 推荐(0) 编辑

2020年2月8日

c使用mutex同步

摘要: #include <stdio.h> #include <unistd.h> #include <pthread.h> void increase(); int sum = 0; pthread_mutex_t mutex; int main() { // init mutex pthread_mu 阅读全文

posted @ 2020-02-08 23:04 luckygxf 阅读(700) 评论(0) 推荐(0) 编辑

1290. 二进制链表转整数

摘要: int getDecimalValue(struct ListNode* head){ int res = 0; while (head) { res <<= 1; res += head->val; head = head->next; } return res; } 阅读全文

posted @ 2020-02-08 18:17 luckygxf 阅读(139) 评论(0) 推荐(0) 编辑

c date格式

摘要: // // Created by gxf on 2020/2/8. // #include <time.h> #include <stdio.h> int main(int argc, char **argv) { time_t seconds; time(&seconds); printf("se 阅读全文

posted @ 2020-02-08 11:52 luckygxf 阅读(511) 评论(0) 推荐(0) 编辑

2020年2月7日

c udp server client demo

摘要: server.c // // Created by gxf on 2020/2/7. // #include <stdio.h> #include <sys/socket.h> #include <arpa/inet.h> #include <stdlib.h> #define BUFFSIZE 1 阅读全文

posted @ 2020-02-07 22:42 luckygxf 阅读(548) 评论(0) 推荐(0) 编辑

c获取时间

摘要: 1. 获取时间戳gettimeofday(struct timeval*tv,struct timezone *tz) 2. time(time_t *t)获取日期 #include <stdio.h> #include <sys/time.h> #include <unistd.h> #inclu 阅读全文

posted @ 2020-02-07 21:44 luckygxf 阅读(587) 评论(0) 推荐(0) 编辑

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 46 下一页

导航