![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
UNIX
文章平均质量分 52
mikon_lee
这个作者很懒,什么都没留下…
展开
-
OJ
最近闲的无聊,就做起OJ ,通过多进程。 架构为:服务器开绑定一个ip,接收代码。(直接开了一个很大的buffer接收一次,有点敷衍)。 每接到一个请求,在一个函数中解决。 此函数的任务先用system()函数编译该程序。如果编译成功fork()一个子进程。通过 if(pid>0) { FILE *f_time; FILE *f_mem; sprintf(path_t原创 2013-05-14 21:42:01 · 639 阅读 · 0 评论 -
条件变量
#include #include #include #include #include #include #include #include //#include #include #include #include #include #include #define MAXNITEMS 1000000 #define MAXNTHREADS 10原创 2013-08-14 16:07:01 · 549 阅读 · 0 评论 -
《unix网络编程》生产者消费者问题
首先是多个生产者单个消费者问题: /* include main */ #include #include #include #include #include #define NBUFF 10 #define MAXNTHREADS 100 int nitems, nproducers; /* read-only by producer and consumer原创 2013-08-07 20:35:22 · 795 阅读 · 0 评论 -
自动登录
gedit /etc/lightdm/lightdm.conf. 修改配置文件[SeatDefaults] allow-guest=false autologin-user=root autologin-user-timeout=0 autologin-session=lightdm-autologin user-session=ubuntu greeter-session=un原创 2013-07-04 11:50:28 · 752 阅读 · 0 评论 -
sh细节
从一个shell小白来写一个if else shell,鸟哥的代码居然也是错的!!! 他的sh17.sh代码如下: #!/bin/bash # Program # Use ping command to check the network's PC state. # History # 2009/02/18 VBird first release PATH=/b原创 2013-07-08 21:24:25 · 555 阅读 · 0 评论 -
生成随机数
// 随机数的生成 #include #include #include #include using namespace std; // 随机生成某范围的随机整数,调用前记得srand设置种子 int range_random(int start, int end) { return ( start + rand() % (end - st原创 2013-06-07 15:35:19 · 509 阅读 · 0 评论 -
C操作mysql
#if defined(_WIN32) || defined(_WIN64) //为了支持windows平台上的编译 #include #endif #include #include #include #include "mysql.h" //我的机器上该文件在/usr/local/include/mysql下 //定义数据库操作的宏,也可以不定义留着后面直接写进代码 #原创 2013-06-06 18:06:15 · 482 阅读 · 0 评论 -
signal()
进程间发送信号就靠signal函数了。 看看这段代码:#include #include void handler(int signum) { printf("recevie the signal %d\n",signum); return ; } int main(void) { signal(SIGINT,handler); while (1);原创 2013-06-05 21:50:57 · 572 阅读 · 0 评论 -
命名管道
无名管道: #include #include #define MAXLINE 80 int main(void) { int n; int fd[2]; pid_t pid; char line[MAXLINE]; if (pipe(fd) < 0) { perror("pipe"); exit(1); } if ((pid = fork()) < 0)原创 2013-06-04 22:58:20 · 495 阅读 · 0 评论 -
apache2
在Ubuntu中安装apache 安装指令:sudo apt-get install apache2 安装结束后: 产生的启动和停止文件是:/etc/init.d/apache2 启动:sudo apache2ctl -k start 停止:sudo apache2ctl -k stop 重新启动:sudo apache2ctl -k restart 另附:原创 2013-06-03 11:43:30 · 415 阅读 · 0 评论 -
linux 查询某个目录下的文件中是否有某个字符串
比如想查询alidata下存在哪个html文件中含有"work"字符串 find /alidata -name *.html | xargs grep 'work' xargs用于接受结果进行之后的命令 vim 匹配字符串直接用/或?原创 2013-05-31 21:03:40 · 588 阅读 · 0 评论 -
中断处理
中断处理一般不是纯软件来实现的,需要硬件的支持。通过对中断的学习有助于更深入的了解系统的一些底层原理,特别是驱动程序的开发。 主要内容: 什么是中断中断类型中断相关函数中断处理机制中断控制方法总结 1. 什么是中断 为了提高CPU和外围硬件(硬盘,键盘,鼠标等等)之间协同工作的性能,引入了中断的机制。 没有中断的话,CPU和外围设备之间协同工作可能只有轮询这个方法:CPU定期检转载 2013-05-29 16:08:10 · 528 阅读 · 0 评论 -
extern explicit 修饰符
extern指此变量或函数在外部文件中定义了,避免运行时出错。 explicit 是用来避免构造函数强制转化参数类型 如下 class a { int value; public: explicit a(int arg ) { value =arg; }; }; int main() { a x=1; } 编译error 去掉explicit后只有warn原创 2013-05-27 21:38:59 · 588 阅读 · 0 评论 -
c++ STL源码
linux c++ STL源码主要在/usr/include/c++/4.6.3文件下,仔细看的话就会发现好多不同文件夹下的相同文件,其实有的是这种形式: #ifdef _GLIBCXX_DEBUG # include #endif #ifdef _GLIBCXX_PROFILE # include #endif原创 2013-05-27 20:11:28 · 1401 阅读 · 0 评论 -
UNIX 环境高级编程
fork() 新建子进程,返回两个值 子进程返回0,父进程返回子进程pid execlp("bin/ls","ls",arg[0],arg[1],...(char *)0) 如果调用成功,进程自己的执行代码就会变成加载程序的代码,execlp()后边的代码也就不会执行了 kill(pid,SIGXXX) SIGTERM暂时不回收进程内存,立刻回收SIGKILL. wait(&status)原创 2013-05-17 18:09:02 · 671 阅读 · 0 评论 -
unix条件变量
条件变量(Condtion Variable)是在多线程程序中用来实现“等待->唤醒”逻辑常用的方法。举个简单的例子,应用程序A中包含两个线程t1和t2。t1需要在bool变量test_cond为true时才能继续执行,而test_cond的值是由t2来改变的,这种情况下,如何来写程序呢?可供选择的方案有两种: 第一种是t1定时的去轮询变量test_cond,如果test_cond为false,原创 2013-08-05 10:15:16 · 882 阅读 · 0 评论