From: mindentropy@gmail.com (mindentropy)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Regarding mmap synchronization.
Date: Mon, 19 Sep 2011 00:42:10 +0530 [thread overview]
Message-ID: <201109190042.10915.mindentropy@gmail.com> (raw)
In-Reply-To: <CABi1daHc=GJwFj+OA2xZ8=QmPoyxy8j83okc47j9G7FKfkX10w@mail.gmail.com>
On Monday 19 Sep 2011 12:19:29 AM Dave Hylands wrote:
> The way I normally deal with this is to use 2 indicies, a get index
> and a put index. One of the indicies if only ever written by kernel
> space, and the other is only ever written by user space.
>
That is the setup I have now.
>
> You make the circular buffer be a power of 2 in size, and you
> determine the number of items in the queue by subtracting the get
> index from the put index.
I am worried about the subtraction. Is it safe to subtract when the put index
is in the process of incrementing by the kernel?
My queue size is always a power of two and avoid the modulus operation by '&'
with (2^n)-1.
> If the items in the circular buffer are in cached memory, then I
> normally try to make each item be an exact multiple of the cache line
> size. I find using uncached memory is generally better for this type
> of thing (the accesses are slower, but may be faster after accounting
> for the cache management).
>
I am having a chunked buffer. So the queue items are memory chunks ranging from
PAGE_SIZE*n to PAGE_SIZE*1. So I have a index to the chunk, index to item
inside the chunk for read and write. For the user its invisible and sees it as
one big chunk of memory with a read and a write index.
next prev parent reply other threads:[~2011-09-18 19:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-18 18:02 Regarding mmap synchronization mindentropy
2011-09-18 18:49 ` Dave Hylands
2011-09-18 19:12 ` mindentropy [this message]
2011-09-18 19:56 ` Dave Hylands
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201109190042.10915.mindentropy@gmail.com \
--to=mindentropy@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.