
语言-c-glibc-posix
文章平均质量分 80
google_lover
这个作者很懒,什么都没留下…
展开
-
read-write ordinary file
/********************************write_test.c**************/#include #include #include #include #include #include #include #include原创 2011-08-13 19:44:39 · 791 阅读 · 0 评论 -
IPC-msg 消息队列
int msgget(key_t key, int msgflg); int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); ssize_t msgrcv(int msqid原创 2011-08-27 20:40:47 · 970 阅读 · 0 评论 -
IPC-shm 共享内存
a series of functions int shmget(key_t key, size_t size, int shmflg);//两个进程若想共用一个物理内存区,只需在此处填写相同的key_t//返回共享内存标示符,作为shmat的参数shm原创 2011-08-27 19:37:57 · 1243 阅读 · 0 评论 -
FIFO 两个进程同时写同一个FIFO
将“IPC-FIFO ,open and read are blocked”那篇的test1.c( line25)的sleep(10)的注释取消,便是本文的test1.c目的是在10秒之内(从test1开始运行算起),把test2和test3都运行起来即在test原创 2011-08-27 16:28:34 · 2175 阅读 · 0 评论 -
socket-几点
1.tcp连接,服务器端的accept返回的套接字怎么和客户端对应的套接字通信?tcp server端进行的动作有//创建STREAM socketint server_sockfd;server_sockfd = socket(AF_INET, SOCK_STREAM, 0);//想要监视的地址及端口struct sockaddr_in server_address;原创 2012-05-30 19:01:59 · 1108 阅读 · 0 评论 -
IPC-sem 信号量
int semget(key_t key, int nsems, int semflg); int semop(int semid, struct sembuf *sops, unsigned nsops);The elements of this struct原创 2011-08-27 21:52:11 · 1151 阅读 · 0 评论 -
thread7 进程结束时机
线程结束时机:执行到pthread_exit()函数时执行到线程函数的最后一个}时(但对主线程而言,执行到main函数的最后一个}时,编译器在此处放一个exit(),从而使进程结束,从而使所有线程结束)what's more,如果是子线程是分离的,则结束掉之后原创 2011-08-25 22:45:55 · 1389 阅读 · 0 评论 -
threads4 计数信号量
//beginning linux programming chapter12[root@localhost ch12]# cat thread3.c#include #include #include #include #include #include vo原创 2011-08-24 20:40:17 · 768 阅读 · 0 评论 -
threads5 互斥信号量type
互斥信号量is互斥量by short互斥量的类型/**********/usr/include/pthread.h********** Mutex types. */enum{ PTHREAD_MUTEX_TIMED_NP, PTHREAD_MU原创 2011-08-25 17:07:29 · 899 阅读 · 0 评论 -
sockets-file system sockets (AFX_UNIX)
[root@localhost chapter15]# cat server1.c /* Make the necessary includes and set up the variables. */#include #include #include #include #include #include int main(){ int server_sockf原创 2011-08-28 15:05:44 · 1741 阅读 · 0 评论 -
sockets-network sockets (AFX_INET)
[root@localhost chapter15]# cat server3.c /* Make the necessary includes and set up the variables. */#include #include #include #inc原创 2011-08-28 17:26:57 · 1066 阅读 · 0 评论 -
sockets-getname.c网络信息
[root@localhost chapter15]# cat getname.c /* As usual, make the appropriate includes and declare the variables. */#include #include #原创 2011-08-28 18:28:00 · 1181 阅读 · 0 评论 -
fread-fwrite array
/****************************to test fwrite functionn****************************array writer ****** fwrite_test.c8-13 song**************原创 2011-08-13 16:34:49 · 941 阅读 · 0 评论 -
extern ,EXPORT_SYMBOL
///////////////////////a.c#includevoid fun(void);int var_public_b=1;//int main(){printf ("main start\n");var_public_b=6;//fu原创 2011-08-02 17:25:30 · 1175 阅读 · 0 评论 -
linux c语言实现队列及用于生产者消费者模型
1.多线程模型2.cpu调度下的xianchegn原创 2014-10-20 14:24:02 · 4901 阅读 · 0 评论 -
socket-select ,poll ,epoll
[root@localhost chapter15]# cat server5.c /* For our final example, server5.c, we include the sys/time.h and sys/ioctl.h headers in place of signal.h in our last program and declare some ex原创 2011-08-29 10:25:29 · 949 阅读 · 0 评论 -
sockets-select.c
[root@localhost chapter15]# cat select.c /* Begin as usual with the includes and declarations and then initialize inputs to handle input from the keyboard. */#include #include #include #in原创 2011-08-29 08:39:57 · 936 阅读 · 0 评论 -
sockets-多进程服务多客户
[root@localhost chapter15]# cat server4.c /* This program, server4.c, begins in similar vein to our last server, with the notable addi原创 2011-08-28 21:58:26 · 727 阅读 · 0 评论 -
threads 2-局部变量和全局变量
main里面定义的变量都是属于主线程的主线程创建的子线程不能访问之需用全局变量进行线程间通信[root@localhost ch12]# cat test4.c#include #include #include #include #include vo原创 2011-08-24 17:37:06 · 1173 阅读 · 0 评论 -
processes 1 启动进程
beginning linux programming ch111.use system( ) in glibc[root@localhost chapter11]# cat system1.c #include #include int main(){ printf("Running ps with system\n"); system("ps -e");原创 2011-08-24 10:05:03 · 968 阅读 · 0 评论 -
the CFLAGS of make -define macro
[root@localhost test]# lstest1.c[root@localhost test]# cat test1.c #include#ifdef DEBUG#define DBG(...) fprintf(stderr, " DBG(%s, %s(), %d): ", __FILE__, __FUNCTION__, __LINE__); fprintf(stderr,原创 2011-08-23 10:19:09 · 2027 阅读 · 0 评论 -
processes 2 信号
//父子进程信号通信//signal 接收信号//kill 发送信号[root@localhost chapter11]# cat alarm.c /* In alarm.c, the first function, ding, simulates an alarm c原创 2011-08-24 10:05:24 · 814 阅读 · 1 评论 -
boost asio timer,linux time and timer
应用层:计时函数@REF1time(2) / time_t (秒)ftime(3) / struct timeb (毫秒)gettimeofday(2) / struct timeval (微秒)clock_gettime(2) / struct timespec (纳秒)gmtime / localtime / timegm / mktime / strftime / struc原创 2015-03-13 22:15:55 · 1014 阅读 · 0 评论 -
c,c++语言历史
符号的一个问题,记录一下http://www.unixresources.net/linux/clf/linuxK/archive/00/00/71/60/716080.htmlEXPORT_SYMBOL() 被export的符号,是用来给加载模块时链接时用的, 编译内核自身时, 和export 应该是没有关系的. 看是否包含了对应的头文件, console.c是被编译为模块, 还是编原创 2011-08-01 22:21:10 · 10379 阅读 · 0 评论 -
语言对比-语法
引用符号:c++使用#include引入特定文件c#使用using namespace引入命名空间即可,无需指定特定的文件java使用import引入包构造函数c++ c# java都是把与类同名的一个函数当做构造函数析构函数c++是类同名的一个函数前加上"~"c#是类同名的一个函数前加上"~",但是编译器会将其转换为finalize的一个重写方法java没有,...原创 2016-01-03 13:38:00 · 564 阅读 · 0 评论 -
linux 各应用库
转自http://www.cppblog.com/merlinfang/archive/2014/12/26/209311.aspx下次造轮子前先看看现有的轮子吧值得学习的C语言开源项目- 1. Webbench Webbench是一个在linux下使用的非常简单的网站压测工具。它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工转载 2016-08-07 11:08:27 · 3497 阅读 · 0 评论 -
io-同步 异步 阻塞 非阻塞
异步io是kernel帮你的线程盯着该线程所要的数据是否可用,而线程可以去做别的事情。当数据可用时kernel通知你的线程。需要利用事件等机制来完成。同步io是你的线程自己去向内核查询所要的数据是否可用。在查询的时候,数据不可用的话:如果内核将这个线程塞进等待队列,直到数据可用时,内核将线程加进可运行队列,并将可用数据给它,则是阻塞型io;如果内核不将其塞进等待队列,而是直接给他一个e原创 2011-10-28 11:47:50 · 1140 阅读 · 0 评论 -
threads 1 利用变量同步
[root@localhost ch12]# cat test1.c #include #include #include #include #include char message[]="hello";void* thread_function(void *ar原创 2011-08-24 10:33:16 · 1550 阅读 · 1 评论 -
threads6 线程脱离属性detach
//beginging linux programming ch12[root@localhost ch12]# cat thread5.c #include #include #include #include void *thread_function(void原创 2011-08-25 21:36:19 · 1025 阅读 · 0 评论 -
FIFO 和普通文件
FIFO; a named pipe[root@localhost ch13]# cat fifo3.c /*************write*****/#include #include #include #include #include #include原创 2011-08-26 18:30:08 · 3063 阅读 · 1 评论 -
cmake--Makefile
//the dir structure,all in one dir[root@localhost hello_cmake_test]# lltotal 20-rw-r--r-- 1 root root 95 2011-07-17 03:17 func_1.c-原创 2011-08-22 16:49:44 · 1103 阅读 · 0 评论 -
sqlite移植到mini2440
take notes---一、开发环境:Mini2440,Linux_2.6.32.2内核,fedora 9arm-linux-gcc-4.3.3二、移植步骤下载源码http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz为3.7.7.1版 1.解压数据库源文件并进入解压后的目录,如下:tar -zxvf sqlite-aut原创 2011-08-20 17:46:14 · 1199 阅读 · 0 评论 -
automake--Makefile
//the dir structure[root@localhost hello]# ll total 8drwxr-xr-x 2 root root 4096 2011-07-16 22:08 includedrwxr-xr-x 3 root root 4096 201原创 2011-08-22 11:03:41 · 826 阅读 · 0 评论 -
unix环境高级编程 代码编译
1 获得源码 从apue的官方网站http://www.apuebook.com/下载 源码。(点击here直接下载) 在windows下载后用U盘拷到linux系统下找个目录解压 tar -zxvf src.tar.gz 在当前目录下解压 通过pwd查看你解压转载 2011-08-15 22:32:46 · 947 阅读 · 0 评论 -
文件系统-文件和目录在硬盘上的存储方式
refer to http://blog.youkuaiyun.com/engerled/article/details/6234045文件系统指文件存在的物理空间,linux系统中每个分区都是一个文件系统,都有自己的目录层次结构。linux会将这些分属不同分区的、单独的文件系统按一定原创 2011-08-19 11:47:56 · 8811 阅读 · 0 评论 -
mysql移植到mini2440
ubuntu10.04离线安装mysql_5.1.32.tar.gzrefer tohttp://wenku.baidu.com/view/f78eb34be45c3b3567ec8be7.html解压后进入# ./configure --prefix=/usr/local/mysql# make#make install1. groupadd mysql2. mkdir /...原创 2011-08-20 21:33:52 · 1265 阅读 · 0 评论 -
threads3-thread8.c and thread8a.c
begging linux programming chapter 12.8 [root@localhost ch12]# cat thread8.c #include #include #include #include #define NUM_THREADS原创 2011-08-24 18:44:17 · 1163 阅读 · 0 评论 -
hashmap c
问题提出:假如一个结构体,记录有学号,姓名。现在内存块中存在着一批此类结构体。如果已知一个学号,要从这些结构体中找出对应的姓名。问题解决方法:如果使用链表保存这些结构体,就要遍历这个链表中的结构体,比较每个结构体的学号成员,如果相等就返回这个结构体,从而得到结构体的姓名成员。但是遍历效率太低,浪费cpu,有点费电。不如使用hash表直接定位到对应的结构体,而不必遍历。具体做法见原创 2012-10-20 15:36:48 · 1100 阅读 · 0 评论 -
libev
http://code.taobao.org/p/ezlibs/src/opensrc/libev/offical/tutorial_libev/http://c4fun.cn/blog/2014/03/06/libev-study/http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod原创 2016-08-07 17:30:42 · 3195 阅读 · 2 评论 -
fread-fwrite pointer
/****************************to test fwrite functionn****************************pointer writer8-13 song******************************原创 2011-08-13 17:42:23 · 792 阅读 · 0 评论