🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.comp.os
Article #23

Re: ?????????????????????????

#23
From: Buzzard
Date: Fri, 23 Dec 2005 01:38
75 lines
5227 bytes
��ı��ⶼ��???���ַ������ʲô����

��ô�����׵�ַ�����㿴˵���ɣ�
void *mmap(void *addr, size_t len, int prot, int flag, int filedes,
off_t off );
The addr argument lets us specify the address of where we want the
mapped region to start. We normally set this to 0 to allow the system
to choose the starting address. The return value of this function is
the starting address of the mapped area.
���˵��ӳ��������ڴ�ռ��ַҪô����addr����ָ����Ҫô��ϵͳѡ��

���⿴��flag����ɣ�
MAP_FIXED
 The return value must equal addr. Use of this flag is discouraged, as
it hinders portability. If this flag is not specified and if addr is
nonzero, then the kernel uses addr as a hint of where to place the
mapped region, but there is no guarantee that the requested address
will be used. Maximum portability is obtained by specifying addr as 0.

Support for the MAP_FIXED flag is optional on POSIX-conforming
systems, but required on XSI-conforming systems.

MAP_SHARED
 This flag describes the disposition of store operations into the
mapped region by this process. This flag specifies that store
operations modify the mapped filethat is, a store operation is
equivalent to a write to the file. Either this flag or the next
(MAP_PRIVATE), but not both, must be specified.
 
MAP_PRIVATE
 This flag says that store operations into the mapped region cause a
private copy of the mapped file to be created. All successive
references to the mapped region then reference the copy. (One use of
this flag is for a debugger that maps the text portion of a program
file but allows the user to modify the instructions. Any modifications
affect the copy, not the original program file.)
 
˵�������MAP_SHARED����ָ�����Ը��ڴ���Ĵ洢�����൱�ڶԸ��ļ���
д���������ʱ����й���ʱ��ͻ�Ŀ��ܣ���Ҫ��̼�ͬ��ԭ�
MAP_PRIVATE����ָ���������ڴ��п���һ��������ԭ��˵��copy���ҷ���ɸ���Ӧ��
û����ɣ�������Ը��������ֻӰ�����������û�ж�ԭʼ�ļ�������

ps.����ժ��Advanced Programming in the UNIX Environment: Second
Edition

On Thu, 22 Dec 2005 18:25:08 +0800, yong <luoyong_zh@hotmail.com>
wrote:

>�����ļ��ĸ���,��һ���ļ�������ڴ����ڴ�ռ��׵�ַ
>
>Buzzard wrote:
>> ��˵��û����������ǰ��Ҳ�Ѿ�˵�ˣ��Ƿ񡱿��ܡ���ͻ��
>> ���ûָ����ȷ��flags�����Ҫ����ͬ����
>> �ʼ���������Ҳ��snnn������Ҫָ��MAP_PRIVATE
>> ����Ż��ÿ�����һ����ӳ���ļ��ĸ�����
>> 
>> On Wed, 21 Dec 2005 23:55:11 +0800, yong
>> <yong.personal.mail@gmail.com> wrote:
>> 
>> 
>>>�Ѿ�ӳ��Ϊ�ڴ�ռ��˾Ϳ��Ա����ͻ,mmap�ڴ����UNIXϵͳ���涼��ϵͳ����,
>>>����������⺯����ɵ�,���Բ����ɳ���ֱ�Ӷ��ļ�,���Ǻ��ļ�����һ��ϵͳ��
>>>��,����д��ݵ����"�ڴ�"��,��ϵͳ���ܽ���д���ļ�,ϵͳ�Ѿ��Ѷ�д����
>>>�ź���,man��һ��mmap()
>>>
>>>void * mmap(void *start, size_t length, int prot , int flags, int fd,
>>>off_t offset);
>>>
>>>���Ը�flags��������һ��ֵMAP_SHARED,����Ϳ����ڶ������й������ռ�,
>>>��д�������msync()�������ڵ����д���ļ���.
>>>
>>>Buzzard wrote:
>>>
>>>>mmap���ڴ�ӳ���ļ����Ǻ���˵���ܳ�ͻ��
>>>>
Technical Details
Message-ID: <blkmq1l1i32ffbdnsnrsqbpou2om4l217h@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!news.cn99.com!news.yaako.com!not-for-mail
References: <86zmnhk2e5.fsf@bbs.cumt.edu.cn> <do8uas$jh0$1@news.yaako.com> <6lniq157h273cfu8lr0gm6fnlohns7oqqo@4ax.com> <dobtr0$gsg$1@news.yaako.com> <4nvjq15aenvcoi9ql5pdtpr1k6v894cv9s@4ax.com> <dodutd$mj1$1@news.yaako.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11047e,3be68aeed99f8432
X-Google-Attributes: gid11047e,public
X-Google-Language: Chinese,GB
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!news.cn99.com!news.yaako.com!not-for-mail
From: Buzzard <Buzzard@126.com>
Newsgroups: cn.comp.os,cn.comp.lang.c
Subject: Re: ?????????????????????????
Date: Fri, 23 Dec 2005 09:38:18 +0800
Organization: Bentium Ltd. (CN99)
Lines: 75
Message-ID: <blkmq1l1i32ffbdnsnrsqbpou2om4l217h@4ax.com>
References: <86zmnhk2e5.fsf@bbs.cumt.edu.cn> <do8uas$jh0$1@news.yaako.com> <6lniq157h273cfu8lr0gm6fnlohns7oqqo@4ax.com> <dobtr0$gsg$1@news.yaako.com> <4nvjq15aenvcoi9ql5pdtpr1k6v894cv9s@4ax.com> <dodutd$mj1$1@news.yaako.com>
NNTP-Posting-Host: 61.144.207.45
Mime-Version: 1.0
Content-Type: text/plain; charset=GB2312
Content-Transfer-Encoding: 8bit
X-Trace: news.yaako.com 1135301499 18549 61.144.207.45 (23 Dec 2005 01:31:39 GMT)
X-Complaints-To: usenet@news.yaako.com
NNTP-Posting-Date: Fri, 23 Dec 2005 01:31:39 +0000 (UTC)
X-Newsreader: Forte Free Agent 3.1/32.783