From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) From: arisawa In-Reply-To: Date: Sun, 14 Sep 2014 13:41:00 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: <26DF63C8-B7D9-4BEC-86EE-1DEBEDCC0482@ar.aichi-u.ac.jp> References: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Subject: Re: [9fans] segattach in telnetd Topicbox-Message-UUID: 167b9b0a-ead9-11e9-9d60-3106f5b1d025 Hello cinap, My experiment here. void main(int argc, char *argv[]) { char *ap; char buf[1]; ARGBEGIN{ default: usage(); }ARGEND =09 ap =3D segattach(0,"share",0,1024); print("%p\n",ap); // ffffffff error /* compare */ ap =3D sbrk(0); print("sbrk %p\n",ap); // 6cb0 ap +=3D 2*1024*1024; print("%p\n",ap); // 206cb0 ap =3D segattach(0, "shared", ap, 1024); print("%p\n",ap); // 206000 read(0,buf,1); } we can find the allocated share memory: term% cat /proc/612768/segment Stack defff000 dffff000 1 Text R 1000 6000 1 Data 6000 7000 1 Bss 7000 7000 1 Shared 206000 207000 1 term%=20 note that 0x206cb0 + 0x400 > 0x20700. if we believe that we have a memory of range [mp,mp+1024) by executing mp =3D share(1024) then we will fail. Kenji Arisawa 2014/09/14 12:17=E3=80=81cinap_lenrek@felloff.net =E3=81=AE=E3=83=A1=E3=83= =BC=E3=83=AB=EF=BC=9A > it should round va down and va+len up as neccesary > to make them page aligned. but the initial passed > range should be covered by the created segment > in any case.