摘要:
(1)删除包含特定字符的行:g/pattern/d(全局范围内):1,20g/pattern/d(删除1~20行内匹配的行)(2)删除不匹配的行:v/pattern/d:g!/pattern/d 阅读全文
posted @ 2013-05-01 21:06
robotke1
阅读(1701)
评论(0)
推荐(0)
摘要:
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <unistd.h> 5 #include <semaphore.h> 6 #include <sys/types.h> 7 #include <dirent.h> 8 #include <pthread.h> 9 #include <errno.h>10 #include <signal.h>11 #include < 阅读全文
posted @ 2013-05-01 20:26
robotke1
阅读(764)
评论(0)
推荐(0)
摘要:
(1)通过全局变量进行传递struct food{ int a; int b; int c;};struct food apple;void* task1(void* arg){ apple.a = 27; apple.b = 12; apple.c = 39; pthread_exit((void*)&apple);}int main(int argc, char *argv[]){ pthread_t thrd1, thrd2, thrd3; void* tret; pthread_create(&thrd1, NULL, (vo... 阅读全文
posted @ 2013-05-01 20:06
robotke1
阅读(486)
评论(0)
推荐(0)
摘要:
进程中的任一线程调用了exit,_Exit或者_exit,那么整个进程都会终止。 单个线程在不终止整个进程的情况下停止它的控制流,有三种方式:(1)线程只是从启动例程中返回,返回值是线程的退出码。(2)线程可以被同一进程中的其他线程取消。(3)线程调用pthread_exit。1、单个线程调用exit,_Exit或者_exitvoid* task1(void* arg){ while (1) {sleep(1);printf("thread1 running...\n");} return NULL;}void* task2(void *arg){ while (1) {s 阅读全文
posted @ 2013-05-01 18:25
robotke1
阅读(506)
评论(0)
推荐(0)
摘要:
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <unistd.h> 5 #include <semaphore.h> 6 #include <sys/types.h> 7 #include <dirent.h> 8 #include <pthread.h> 9 #include <errno.h>10 #include <signal.h>11 #include < 阅读全文
posted @ 2013-05-01 15:48
robotke1
阅读(344)
评论(0)
推荐(0)
摘要:
(转载)http://www.cnblogs.com/mydomain/archive/2011/08/14/2138454.html(2)线程的分离与结合(a) 在任何一个时间点上,线程是可结合的(joinable),或者是分离的(detached)。(b)一个可结合的线程能够被其他线程收回其资源和杀死;在被其他线程回收之前,它的存储器资源(如栈)是不释放的。(c)相反,一个分离的线程是不能被其他线程回收或杀死的,它的存储器资源在它终止时由系统自动释放。线程的分离状态决定一个线程以什么样的方式来终止自己。在上面的例子中,我们采用了线程的默认属性,即为非分离状态(即可结合的,joinable, 阅读全文
posted @ 2013-05-01 15:20
robotke1
阅读(174)
评论(0)
推荐(0)
摘要:
(转载)http://blog.csdn.net/xinu2009/article/details/6768133信号量的数据类型为结构sem_t,它本质上是一个长整型的数。------函数sem_init()用来初始化一个信号量。 它的原型为: extern int sem_init __P ((sem_t *__sem, int __pshared, unsigned int __value));sem为指向信号量结构的一个指针;pshared不为0时此信号量在进程间共享,否则只能为当前进程的所有线程共享;value给出了信号量的初始值。-----函数sem_post( sem_t *se 阅读全文
posted @ 2013-05-01 14:36
robotke1
阅读(271)
评论(0)
推荐(0)
摘要:
(转载)http://blog.chinaunix.net/uid-14966892-id-2780401.htmlHere is an answer from the "Frequently Asked Questions about the GNU C Library" (the FAQ):4.9. How can I find out which version of glibc I am using in the moment?{UD} If you want to find out about the version from the command line s 阅读全文
posted @ 2013-05-01 14:33
robotke1
阅读(444)
评论(0)
推荐(0)

浙公网安备 33010602011771号