Date: Sun, 30 Jul 2006 13:47:47 -0700 From: "Kip Macy" <kip.macy@gmail.com> To: "Divacky Roman" <xdivac02@stud.fit.vutbr.cz> Cc: hackers@freebsd.org Subject: Re: VM question related to faults Message-ID: <b1fa29170607301347p7356d3d6jb922a4c51059d494@mail.gmail.com> In-Reply-To: <20060730200354.GA82547@stud.fit.vutbr.cz> References: <20060730105731.GA64955@stud.fit.vutbr.cz> <20060730200354.GA82547@stud.fit.vutbr.cz>
next in thread | previous in thread | raw e-mail | index | archive | help
>From kern_umtx.c: static int _do_lock(struct thread *td, struct umtx *umtx, long id, int timo) { struct umtx_q *uq; intptr_t owner; intptr_t old; int error = 0; uq = td->td_umtxq; /* * Care must be exercised when dealing with umtx structure. It * can fault on any access. */ for (;;) { /* * Try the uncontested case. This should be done in userland. */ owner = casuptr((intptr_t *)&umtx->u_owner, UMTX_UNOWNED, id); /* The acquire succeeded. */ if (owner == UMTX_UNOWNED) return (0); /* The address was invalid. */ if (owner == -1) return (EFAULT); /* If no one owns it but it is contested try to acquire it. */ if (owner == UMTX_CONTESTED) { owner = casuptr((intptr_t *)&umtx->u_owner, UMTX_CONTESTED, id | UMTX_CONTESTED); if (owner == UMTX_CONTESTED) return (0); /* The address was invalid. */ if (owner == -1) return (EFAULT); On 7/30/06, Divacky Roman <xdivac02@stud.fit.vutbr.cz> wrote: > On Sun, Jul 30, 2006 at 12:57:32PM +0200, Divacky Roman wrote: > > hi, > > > > while working on SoC linuxolator project I am in a need of this: > > > > I need to do some operation on memory like mem1 = mem1 + mem2 etc. > > where the mem1/mem2 access can trigger fault. (memory not mapped or something) > > to make it clear.. I am trying to access user-space memory from kernel. > This needs to be atomic (its an implementation of linux futexes) > > I need to check from kernel if some memory is accessible and then perform an > operation on this memory. All atomically. > > hence I need two things - function which checks wheter the memory is accessible > and something which makes it atomic (some mutex/something which prevents other > process to enter VM to unmap/etc. the memory in question) > > hope its a bit more clear now > > roman > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?b1fa29170607301347p7356d3d6jb922a4c51059d494>