
linux系统编程和API详解
Mark wyz
A person who is willing to be successful
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
linux 解决静态库之间连接顺序的问题
解决库之间链接顺序的问题:gcc main.c -Xlinker “-(” libb.a liba.a -Xlinker “-)”原创 2020-11-27 09:40:36 · 718 阅读 · 0 评论 -
Segmentation fault 调试
gdb coredump 调试1.#设置core大小为无限ulimit -c unlimited2.#设置文件大小为无限ulimit unlimited3. ./a.out 产生core文件4. gdb ./a.out core5.bt 栈回溯,找到发生段错误的函数#include <stdio.h>#include <signal.h>#include <stdlib.h>void func(void){ int * p = 0x0; *p原创 2020-09-26 18:45:38 · 503 阅读 · 0 评论 -
sscanf的用法
部分来源:https://blog.csdn.net/zhouwei1221q/article/details/44890617感谢博主分享。若有侵权,请联系删除```c#include <stdio.h>#include <string.h>int main(int argc, char const *argv[]){ int a=0, b=0, c=0; char buf[64] = {'\0'}; sscanf("2015.04.05", "%d.%d.%原创 2020-08-28 15:36:29 · 482 阅读 · 0 评论 -
linux异步消息:poll、select、epoll
linux异步消息:poll、select、epoll使用举例,epoll并没有深入探讨其参数#include <stdio.h>#include <poll.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h...原创 2020-04-25 14:41:26 · 286 阅读 · 0 评论 -
简单atoi函数功能实现
char str[] = "123456789";int i = 0;int num = 0;int sum = 0;int len = strlen(str);for (i=0; i<len; i++){ sum *= 10; num = str[i] - '0'; sum += num; }fprintf(stderr, "%d\n", sum);...原创 2019-11-08 14:11:15 · 303 阅读 · 0 评论 -
Segmentation fault (core dumped) 调试技巧
Segmentation fault (core dumped) 调试技巧:1.valgrind -v ./a.out,使用valgrind来调试2.coredump调试:https://blog.csdn.net/City_of_skey/article/details/84668911https://www.jianshu.com/p/3e3e8eebd01bcoredump调试技巧...原创 2019-10-22 14:39:30 · 851 阅读 · 0 评论 -
C语言之位段
typedef struct DATA{unsigned char dataOne : 4; //占4个bitunsigned char dataTwo : 4;}DATA_S;sizeof(DATA_S) = 1原创 2019-10-17 16:10:22 · 112 阅读 · 0 评论 -
自己写的DEBUG、OFFSET_OF、CONTAINER_OF宏
#ifdef DEBUG_ON #define DEBUG(format, args...) \ //args...是宏里面特定的不定参数 fprintf(stderr, "[%s]-[%s]-[%d]:" format, __FILE__, __FUNCTION__, __LINE__, ##args) //##是连接符,就是把不定参数连接过来#else #define DEBUG...原创 2019-10-17 15:10:25 · 151 阅读 · 0 评论 -
注释模板
文件头注释模板:/*****************************************************************Copyright ©, 2019-2020, xxx Tech. Co., Ltd.File name: main.cAuthor: xxxVersion: 1.0.0Date: xxxDescription: This module ...原创 2019-10-17 15:02:34 · 200 阅读 · 0 评论 -
线程死锁
来自:https://blog.csdn.net/huang3838438/article/details/18002133#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <pthread.h>#include <signal.h>#inc...原创 2019-10-15 14:06:42 · 102 阅读 · 0 评论 -
wait以及waitpid函数使用
wait以及waitpid函数是干嘛的?可以用来回收子进程结束的相关信息wait:#include <stdio.h>#include <unistd.h>#include <sys/types.h> #include <sys/wait.h>#include <stdlib.h>int main(void){...原创 2019-10-14 13:36:27 · 172 阅读 · 0 评论 -
fopen fclose fread fwrite fseek ftell rewind带缓冲的文件操作函数
fopen fclose fread fwrite fseek ftell带缓冲的文件操作函数:fopen:看一下原型:FILE *fopen(const char *path, const char *mode);FILE *fdopen(int fd, const char *mode);FILE *freopen(const char *path, const char *mod...原创 2019-06-25 10:08:12 · 459 阅读 · 0 评论 -
linux 线程编程
linux 线程编程:pthread_create:#include <pthread.h>int pthread_create(pthread_t * thread, const pthread_attr_t *attr,void *(*start_routine) (void *), void *arg);正确返回0编译的时候要加: -lpthread一般简单使用:...原创 2019-06-25 14:14:19 · 123 阅读 · 0 评论 -
linux 进程间通信--共享内存
linux 进程间通信–共享内存:linux共享内存主要的APIftok()、shmget()、shmat()、shmdt()及shmctl()#include <sys/types.h>#include <sys/ipc.h>key_t ftok(const char *pathname, int proj_id); 是用来生成一个key值的。pathname是...原创 2019-06-25 16:32:09 · 174 阅读 · 0 评论 -
调整rt-linux的进程调度方式为实时调度
调整rt-linux的调度方式为实时调度:pid_t pid = getpid();struct sched_param param;param.sched_priority = sched_get_priority_max(SCHED_FIFO);sched_setscheduler(pid, SCHED_RR, ¶m);pthread_setschedparam(pt...原创 2019-06-25 16:37:36 · 689 阅读 · 0 评论 -
linux的定时器
linux的定时器:定时器:setitimer:#include <sys/time.h>setitimer函数原型:int setitimer(int which, const struct itimerval *new_value,struct itimerval old_value);which參数表示定时器的类型,可选的值有:ITIMER_REAL:以系统真实的...原创 2019-06-26 09:25:01 · 133 阅读 · 0 评论 -
linux的信号:
linux的信号:第一种方式,使用signal函数typedef void (*sighandler_t)(int); //这里的int是用来传信号量的值的sighandler_t signal(int signum, sighandler_t handler);void signalHandler(int signo){switch (signo){case SIGALRM:p...原创 2019-06-26 09:26:16 · 211 阅读 · 0 评论 -
linux进程
linux进程控制编程:1.什么是PID?进程号称为PID,例如PID为1的是init进程,他是所有进程的父进程或者祖宗进程。2.两个函数?getpid:得到当前进程的PIDgetppid:得到当前进程的父进程的PID3.进程是程序的执行过程,可分为三种状态:...原创 2019-07-03 14:59:50 · 141 阅读 · 0 评论 -
进程间通信五种方式的总结:
来源于:https://www.cnblogs.com/zgq0/p/8780893.html转载 2019-07-12 14:31:19 · 223 阅读 · 0 评论 -
open、 close、 write、 read、 lseek详解
linux系统最常用的API函数就是:open、 close、 write、 read、 lseek下面我们用man手册看一下这几个函数的原形和用法:man 1 xxx 查 linux shell 命令,man 2 xxx 查 API, man 3 xxx 查库函数API: open#include <sys/types.h>#include <sys/stat.h&...原创 2019-06-21 10:10:17 · 841 阅读 · 0 评论