ÿÈÕC(3.Linux³£ÓÃCº¯Êý ÄÚ´æ¿ØÖÆƪ)
ÄÚ´æ¿ØÖÆƪ
calloc
free
getpagesize
malloc
mmap
munmap
calloc£¨ÅäÖÃÄÚ´æ¿Õ¼ä£©
Ïà¹Øº¯Êý
malloc£¬free£¬realloc£¬brk
±íÍ·Îļþ
#include <stdlib.h>
¶¨Ò庯Êý
void *calloc(size_t nmemb£¬size_t size);
º¯Êý˵Ã÷
calloc()ÓÃÀ´ÅäÖÃnmemb¸öÏàÁÚµÄÄڴ浥λ£¬Ã¿Ò»µ¥Î»µÄ´óСΪsize£¬²¢·µ»ØÖ¸ÏòµÚÒ»¸öÔªËصÄÖ¸Õë¡£ÕâºÍʹÓÃÏÂÁеķ½Ê½Ð§¹ûÏàͬ:malloc(nmemb*size);²»¹ý£¬ÔÚÀûÓÃcalloc()ÅäÖÃÄÚ´æʱ»á½«ÄÚ´æÄÚÈݳõʼ»¯Îª0¡£
·µ»ØÖµ
ÈôÅäÖóɹ¦Ôò·µ»ØÒ»Ö¸Õ룬ʧ°ÜÔò·µ»ØNULL¡£
·¶Àý
/* ¶¯Ì¬ÅäÖÃ10¸östruct test ¿Õ¼ä*/
#include<stdlib.h>
struct test
{
int a[10];
char b[20];
}
main()
{
struct test *ptr=calloc(sizeof(struct test),10);
}
¡¡
free£¨ÊÍ·ÅÔÏÈÅäÖõÄÄڴ棩
Ïà¹Øº¯Êý
malloc£¬calloc£¬realloc£¬brk
±íÍ·Îļþ
#include<stdlib.h>
¶¨Ò庯Êý
void free(void *ptr);
º¯Êý˵Ã÷
²ÎÊýptrΪָÏòÏÈÇ°ÓÉmalloc()¡¢calloc()»òrealloc()Ëù·µ»ØµÄÄÚ´æÖ¸Õë¡£µ÷ÓÃfree()ºóptrËùÖ¸µÄÄÚ´æ¿Õ¼ä±ã»á±»Êջء£¼ÙÈô²ÎÊýptrËùÖ¸µÄÄÚ´æ¿Õ¼äÒѱ»ÊջػòÊÇδ֪µÄÄÚ´æµØÖ·£¬Ôòµ÷ÓÃfree()¿ÉÄÜ»áÓÐÎÞ·¨Ô¤ÆÚµÄÇé¿ö·¢Éú¡£Èô²ÎÊýptrΪNULL£¬Ôòfree()²»»áÓÐÈκÎ×÷Óá£
¡¡
getpagesize£¨È¡µÃÄÚ´æ·ÖÒ³´óС£©
Ïà¹Øº¯Êý
sbrk
±íÍ·Îļþ
#include<unistd.h>
¶¨Ò庯Êý
size_t getpagesize(void);
º¯Êý˵Ã÷
·µ»ØÒ»·ÖÒ³µÄ´óС£¬µ¥Î»Îª×Ö½Ú£¨byte£©¡£´ËΪϵͳµÄ·ÖÒ³´óС£¬²»Ò»¶¨»áºÍÓ²¼þ·ÖÒ³´óСÏàͬ¡£
·µ»ØÖµ
ÄÚ´æ·ÖÒ³´óС¡£¸½¼Ó˵Ã÷ÔÚIntel x86 ÉÏÆä·µ»ØֵӦΪ4096bytes¡£
·¶Àý
#include <unistd.h>
main()
{
printf(“page size = %d\n”,getpagesize( ) );
}
¡¡
malloc£¨ÅäÖÃÄÚ´æ¿Õ¼ä£©
Ïà¹Øº¯Êý
calloc£¬free£¬realloc£¬brk
±íÍ·Îļþ
#include<stdlib.h>
¶¨Ò庯Êý
void * malloc(size_t size);
º¯Êý˵Ã÷
malloc()ÓÃÀ´ÅäÖÃÄÚ´æ¿Õ¼ä£¬Æä´óСÓÉÖ¸¶¨µÄsize¾ö¶¨¡£
·µ»ØÖµ
ÈôÅäÖóɹ¦Ôò·µ»ØÒ»Ö¸Õ룬ʧ°ÜÔò·µ»ØNULL¡£
·¶Àý
void p = malloc(1024); /*ÅäÖÃ1kµÄÄÚ´æ*/
¡¡
mmap£¨½¨Á¢ÄÚ´æÓ³É䣩
Ïà¹Øº¯Êý
munmap£¬open
±íÍ·Îļþ
#include <unistd.h>
#include <sys/mman.h>
¶¨Ò庯Êý
void *mmap(void *start,size_t length,int prot,int flags,int fd,off_t offsize);
º¯Êý˵Ã÷
mmap()ÓÃÀ´½«Ä³¸öÎļþÄÚÈÝÓ
Ïà¹ØÎĵµ£º
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
·À»ðǽÏàÓ¦¶Ë¿ÚûÓдò¿ª¡£
´ò¿ª·½·¨ÈçÏ£º
vi /etc/sysconfig/iptables
¼ÓÈëÈçϵÄÒ»ÐУº
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3690 -j ACCEPT
ÖØÆôiptables:
/etc/init.d/iptables restart
²é¿´¶Ë¿ÚÊÇ·ñÕæµÄ´ò¿ª:
/etc/init.d/iptables status ......
1. /proc/sys/net/core/rmem_max — ×î´óµÄTCPÊý¾Ý½ÓÊÕ»º³å
2. /proc/sys/net/core/wmem_max — ×î´óµÄTCPÊý¾Ý·¢ËÍ»º³å
3. /proc/sys/net/ipv4/tcp_timestamps — ʱ¼ä´ÁÔÚ(Çë²Î¿¼RFC 1323)TCPµÄ°üÍ·Ôö¼Ó12¸ö×Ö½Ú
4. /proc/sys/net/ipv4/tcp_sack — ÓÐÑ¡ÔñµÄÓ¦´ð
5. /proc/sys/net/ipv4/tcp_windo ......
Linuxϵͳ³öÏÖÎÊÌâʱ£¬ÎÒÃDz»½öÐèÒª²é¿´ÏµÍ³ÈÕÖ¾ÐÅÏ¢£¬¶øÇÒ»¹ÒªÊ¹ÓôóÁ¿µÄÐÔÄܼà²â¹¤¾ßÀ´ÅжϾ¿¾¹ÊÇÄÄÒ»²¿·Ö£¨ÄÚ´æ¡¢CPU¡¢Ó²ÅÌ……£©³öÁËÎÊÌâ¡£ÔÚLinuxϵͳÖУ¬ËùÓеÄÔËÐвÎÊý±£´æÔÚÐéÄâĿ¼/procÖУ¬»»¾ä»°Ëµ£¬ÎÒÃÇʹÓõÄÐÔÄܼà¿Ø¹¤¾ßÈ¡µ½µÄÊý¾Ýֵʵ¼ÊÉϾÍÊÇÔ´×ÔÓÚÕâ¸öĿ¼£¬µ±Éæ¼°µ½ÏµÍ³¸ß¹Àʱ£¬ÎÒÃǾͿÉÒÔÐÞ ......
1 ´´½¨C# DLL£¬ÐèÒªÖ¸¶¨Ó¦ÓÃÀàÐÍΪ“Àà¿â”£¬´úÂ룺
namespace CSLib
{
public class Class1
{
private string name;
public string Name
......