原创 多個C文件生成多個目標的makefile

SOURCES=$(wildcard *.c) PROGS=$(patsubst %.c, %, $(SOURCES)) all:$(PROGS) $(PROGS):%:%.c gcc $^ -o $@ .PHONY:clean cl

原创 使用mmap實現自己的PIPE

程序沒有仔細測試,如果有BUG請留言,謝謝! //pipe.h #ifndef __HEAD_H #define __HEAD_H #define BUFSIZE 4000 //讀寫標誌 typedef enum { READ, W

原创 利用共享存儲實現父子進程間的通信

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ipc.h> #include <sys/shm.h> #de

原创 poll的用法示例(程序還有bug,但只是爲了示例poll的用法就不改了)

//創建PIPENUM個pipe和子進程,子進程負責寫,父進程負責讀 #include <stdio.h> #include <stdlib.h> #include <poll.h> #include <sys/time.h> #incl

原创 函數棧幀和內存分佈筆記

<!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } --> call:函數的調用 ret:函數的返回   函數在調用時要做兩件事: 1、將函數的返回地址保

原创 關於dup2函數

  dup2的功能是複製一個現存的文件描述符,函數原型爲: int dup2(int filedes, int filedes2); 相當於: close(filedes2); fcntl(filedes, f_DUPFD, fi

原创 Ubuntu10.04使用Chrome,輸入法問題

只要刪除後,就必須切換輸入法才能輸入字,否則打不了字。 http://forum.ubuntu.org.cn/viewtopic.php?f=8&t=295899   答案在鏈接的第7樓。    

原创 Ubuntu 10.04安裝tftp

首先執行: sudo apt-get install tftp-hpa tftpd-hpa  然後sodu gedit  /etc/default/tftpd-hpa  修改配置文件爲: # /etc/default/tftpd-

原创 vim python開發環境配置

http://www.pythonclub.org/python-basic/vim

原创 Linux下的多進程間共享資源的互斥訪問

把源代碼運行一遍就知道了 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sy

原创 安裝使用Tex

以下操作在Ubuntu10.04下完成:   sudo apt-get install texlive-full sudo apt-get install okular sudo apt-get install kile   安裝完成後:

原创 文件的讀寫和上鎖

通過使用文件操作,仿真生產者-消費者運行模型。 本實驗中需要打開兩個虛擬終端,分別運行生產者程序(producer)和消費者程序(customer)。 此時兩個進程同時對同一個文件進行讀寫操作。因爲這個文件是臨界資源,所以可以使用文件鎖

原创 實現自己的ls

該程序實現的是ls -al #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include

原创 epoll的簡單用法示例(程序還有bug,但只是爲了示例epoll的用法就不改了)

//epoll用法示例 //創建PIPENUM個pipe和子進程,子進程負責寫,父進程負責讀 #include <stdio.h> #include <stdlib.h> #include <sys/epoll.h> #include <

原创 Linux下利用信號量實現PV操作

假設兩個進程(父子進程)對一個文件進行寫操作,但是這個文件同一時間只能有一個進程進行寫操作。 //利用信號量實現pv操作 #include <stdio.h> #include <stdlib.h> #incl