07 2022 档案

摘要:数据中继select模型 示例:relay_select.c #include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#include <errno.h>#include 阅读全文
posted @ 2022-07-29 21:32 *^VV^* 阅读(30) 评论(0) 推荐(0) 编辑
摘要:通过有限状态机实现文件相互拷贝 示例:relay.c #include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#include <errno.h> #define FIL 阅读全文
posted @ 2022-07-28 09:50 *^VV^* 阅读(24) 评论(0) 推荐(0) 编辑
摘要:多线程交替输出abcd,通过互斥量及信号控制。 示例:abcd_cond.c #include <stdio.h>#include <stdlib.h>#include <string.h>#include <pthread.h>#include <unistd.h>#include <signal 阅读全文
posted @ 2022-07-26 09:14 *^VV^* 阅读(46) 评论(0) 推荐(0) 编辑
摘要:多线程通过竞争获取数据计算是否为质数。 例程:pthread_pool_busy.c #include <stdio.h>#include <stdlib.h>#include <pthread.h>#include <string.h> #define LEFT 30000000#define R 阅读全文
posted @ 2022-07-25 08:21 *^VV^* 阅读(47) 评论(0) 推荐(0) 编辑
摘要:示例:primer.c #include <stdio.h>#include <stdlib.h>#include <pthread.h>#include <string.h> #define LEFT 30000000#define RIGHT 30000200#define THRNUM (RI 阅读全文
posted @ 2022-07-23 21:21 *^VV^* 阅读(23) 评论(0) 推荐(0) 编辑
摘要:创建一个线程并等待线程结束并回收资源 示例:create.c #include <stdio.h>#include <stdlib.h>#include <string.h>#include <pthread.h> static void rountine(void *str) //钩子函数{ pu 阅读全文
posted @ 2022-07-22 08:43 *^VV^* 阅读(121) 评论(0) 推荐(0) 编辑
摘要:进程篇: //功能:创建子线程获取进程编号 pid_t fork(void); pid_t getpid(void); pid_t getppid(void); //功能:完全替换当前线程的内容 extern char **environ; int execl(const char *path, c 阅读全文
posted @ 2022-07-21 08:58 *^VV^* 阅读(39) 评论(0) 推荐(0) 编辑
摘要:1、信号集 类型:sigset_t int sigemptyset(sigset_t *set); int sigfillset(sigset_t *set); int sigaddset(sigset_t *set, int signum); int sigdelset(sigset_t *set 阅读全文
posted @ 2022-07-19 21:04 *^VV^* 阅读(86) 评论(0) 推荐(0) 编辑
摘要:实现一个最大1024个不同定时器,定时时间到执行相应的函数。 头文件anytimer.h #ifndef __ANYTIMER_H__#define __ANYTIMER_H__ #define MAX_TIMER 1024typedef void (*func)(void *); int add_ 阅读全文
posted @ 2022-07-19 09:49 *^VV^* 阅读(53) 评论(0) 推荐(0) 编辑
摘要:实现及管理一个最大1024个不同令牌桶(通过数组管理也可通过链表管理) 头文件:mytbf.h #ifndef __MYTBF_H__#define __MYTBF_H__ #define MAXCOUNT 1024 //设置最大令牌桶数 typedef void tbf_st; //定义数据类型 阅读全文
posted @ 2022-07-18 08:51 *^VV^* 阅读(104) 评论(0) 推荐(0) 编辑
摘要:漏桶示例:slowcat.c #include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <signal.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h 阅读全文
posted @ 2022-07-16 21:21 *^VV^* 阅读(64) 评论(0) 推荐(0) 编辑
摘要:一、信号1、信号的概念 信号是软件中断。 信号的响应依赖于中断。 2、signal(); kill -l信号(标准信号/实时信号) typedef void (*sighandler_t)(int); sighandler_t signal(int signum, sighandler_t hand 阅读全文
posted @ 2022-07-15 20:50 *^VV^* 阅读(19) 评论(0) 推荐(0) 编辑
摘要:pid_t setsid(void); void openlog(const char *ident, int option, int facility); void syslog(int priority, const char *format, ...); void closelog(void) 阅读全文
posted @ 2022-07-15 15:56 *^VV^* 阅读(107) 评论(0) 推荐(0) 编辑
摘要:简易mysh示例:mysh.c #include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/wait.h>#include <glob.h>#include <string.h 阅读全文
posted @ 2022-07-13 21:12 *^VV^* 阅读(52) 评论(0) 推荐(0) 编辑
摘要:1、进程标识符 PID pid_t //进程数据类型 ps //ps及相关命令 ps axf ps axm ps ax -L pid_t getpid(void); //获取当前进程PID pid_t getppid(void); //获取父进程PID 2、进程的产生 pid_t fork(void 阅读全文
posted @ 2022-07-11 20:46 *^VV^* 阅读(64) 评论(0) 推荐(0) 编辑
摘要:环境变量 export //输出所有环境变量 extern char **environ; char *getenv(const char *name); //获取某个环境变量 int setenv(const char *name, const char *value, int overwrite 阅读全文
posted @ 2022-07-10 21:18 *^VV^* 阅读(19) 评论(0) 推荐(0) 编辑
摘要:void Widget::QMutableList(void) //java格式的list { QList<int> list; //QT容器类 QMutableListIterator<int> i(list); //容器类读写迭代器 for(int j=0;j<10;j++) i.insert( 阅读全文
posted @ 2022-07-10 10:35 *^VV^* 阅读(66) 评论(0) 推荐(0) 编辑
摘要:#include <unistd.h> int getopt(int argc, char * const argv[],const char *optstring); //获取命令行参数 extern char *optarg; //参数选项(全局变量) extern int optind, op 阅读全文
posted @ 2022-07-09 21:51 *^VV^* 阅读(33) 评论(0) 推荐(0) 编辑
摘要:正常终止 1、从main函数返回 2、调用exit 3、调用_exit或_Exit //出现不可预料的错误时调用 4、最后一个线程从启动例程返回 5、最后一个线程调用pthread_exit 异常终止 1、调用abort 2、接到一个信号并终止 3、最后一个线程对其取消请求作出相应 atexit() 阅读全文
posted @ 2022-07-08 20:36 *^VV^* 阅读(20) 评论(0) 推荐(0) 编辑
摘要:系统时间获取 time_t time(time_t *tloc); //获取时间戳 struct tm *gmtime(const time_t *timep); //通过时间戳获取时间结构体 struct tm *gmtime_r(const time_t *timep, struct tm *r 阅读全文
posted @ 2022-07-07 21:19 *^VV^* 阅读(18) 评论(0) 推荐(0) 编辑
摘要:1、修改 /etc/profile添加 export QTEDIR=/usr/local/Qt5.6 //设置QT目录 export LD_LIBRARY_PATH=/usr/local/Qt5.6/lib:$LD_LIBRARY_PATH //添加QT库路径 #export QT_QPA_GENE 阅读全文
posted @ 2022-07-07 15:47 *^VV^* 阅读(366) 评论(0) 推荐(0) 编辑
摘要:密码校验: 1、通过UID或name获取用户信息(/etc/passwd) struct passwd *getpwnam(const char *name); struct passwd *getpwuid(uid_t uid); 2、通过gid或grname获取用户组信息(/etc/group) 阅读全文
posted @ 2022-07-07 09:24 *^VV^* 阅读(28) 评论(0) 推荐(0) 编辑