linuxϹ²ÏíÄÚ´æ(shm)ʹÓÃʾÀý
#include <sys/ipc.h>
#include <stdio.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#define PERM IPC_CREAT //S_IRUSR|S_IWUSR
#include <errno.h>
int main(int argc,char **argv)
{
int shmid[2048];
char *p_addr,*c_addr;
if(argc!=2)
{
fprintf(stderr,"Usage:%s InputString\n\a",argv[0]);
return 1;
}
int i =0;
for ( i = 0; i<1024; i++ )
{
char *p = new char[1024*1024];
if ( NULL == p )
{
printf( "error new\n" );
return -1;
}
}
for ( i =0; i<1026; i++ )
{
if((shmid[i]=shmget(IPC_PRIVATE,/*1610612736*/ 1024*1024,PERM))==-1)
{
fprintf(stderr,"Create Share Memory Error:%s\n\a",strerror(errno));
return 1;
}
{
p_addr=(char*)shmat(shmid[i],0,0);
p_addr[0] = i/1000 + '0';
p_addr[1] = i%1000/100 + '0';
p_addr[2] = i%100/10 + '0';
p_addr[3] = i%10 + '0';
p_addr[4] = '\0';
printf( "%d, %s\n", i, p_addr );
}
}
}
Ïà¹ØÎĵµ£º
ÐéÄâ»úlinux°æ±¾£ºredhat9.0
×ܽáһϣºÒª±£Ö¤ÐéÄâ»úϵͳ¿ÉÒÔÉÏÍø£¬µÃÏȽâ¾öÐéÄâ»úºÍÕæʵÖ÷»úµÄÁ¬½Ó¹Øϵ¡£VMwareÖ÷Òª¸ø³ö3ÖÖģʽ£¬ÎÒÃdz£ÓõÄÓГbridge£¨ÇŽӣ©”ºÍ
“Nat£¨ÍøÂçµØַת»»£©”·½Ê½¡£ÐéÄâ»úÉèÖ÷½·¨£ºµ¥»÷“ÐéÄâ»ú”→“ÉèÖÔ→“ÒÔÌ«Íø£¬È»ºóÑ¡ÔñÁ ......
Ò»£®Ìî¿ÕÌ⣺
1. ÔÚLinuxϵͳÖУ¬ÒÔÎļþ·½Ê½·ÃÎÊÉ豸 ¡£
2. LinuxÄÚºËÒýµ¼Ê±£¬´ÓÎļþ/etc/fstabÖжÁÈ¡Òª¼ÓÔصÄÎļþϵͳ¡£
3. LinuxÎļþϵͳÖÐÿ¸öÎļþÓÃi½ÚµãÀ´±êʶ¡£
4. È«²¿´ÅÅÌ¿éÓÉËĸö²¿·Ö×é³É£¬·Ö±ðΪÒýµ¼¿é ¡¢×¨ÓÃ¿é ¡¢ i½Úµã±í¿é ºÍ´æ´¢¿éÊý¾Ý¡£
5. Á´½Ó·ÖΪ£ºÓ²Á´½Ó ºÍ ·ûºÅÁ´½Ó¡£
6. ³¬¼¶¿é°üº¬ÁËi½Úµã±í ......
°²×°ÊµÀý£ºImageMagickµÄ°²×°·½·¨
ImageMagickµÄ°²×°·½·¨ÓÐRPM·½Ê½ºÍSOURCE·½Ê½¡£Ä¿Ç°×îаæÊÇImageMagick-6.5.5¡£¿ÉÒÔ´ÓÕâ¸öÍøÖ·ÏÂÔØ£º http://www.imagemagick.org
°²×°²½Ö裺
£±£®sshÁ¬½ÓLinux·þÎñÆ÷
£²£®°ÑÏÂÔصݲװÎļþ·Åµ½Êʵ±µÄÎļþ¼ÐÏ¡£ÀýÈ磺cd /usr/local/src¡£»òÕßÖ±½ÓÔÚ·þÎñÆ÷ÉÏÏÂÔØ¡£
3£®½âѹÏÂÔØÎļ ......
linux shell pwd ÏÔʾµ±Ç°Â·¾¶
¼ÙÈôÓÐtest.cpp
g++ test.cpp -o test
./test
ÏëÔÚtestÖÐÕÒµ½µ±Ç°Ö´ÐгÌÐòËùÔڵķ¾¶
¿ÉÒÔÔÙtest.cppÖÐʹÓÃreadlinkº¯Êý
¾ßÌå¼ûÈçÏÂʵÀý£º
#include<iostream>
#include<unistd.h>
#include<dirent.h>
#include<string.h>
#include<string>
using ......
/******************************
*
* server.c
*
******************************/
#include<stdio.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<errno.h>
#include<string.h>
#include<netinet/in.h>
#include<sys/wait.h> ......