From 6bb0e5cb462431a2a86e4263d027ba8ad04eddc4 Mon Sep 17 00:00:00 2001 From: iedowse Date: Sun, 22 Jun 2003 02:18:31 +0000 Subject: Replace the code for reading and writing the kernel message buffer with a new implementation that has a mostly reentrant "addchar" routine, supports multiple message buffers in the kernel, and hides the implementation details from callers. The new code uses a kind of sequence number to represend the current read and write positions in the buffer. This approach (suggested mainly by bde) permits the read and write pointers to be maintained separately, which reduces the number of atomic operations that are required. The "mostly reentrant" above refers to the way that while it is now always safe to have any number of concurrent writers, readers could see the message buffer after a writer has advanced the pointers but before it has witten the new character. Discussed on: freebsd-arch --- sbin/dmesg/dmesg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sbin') diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c index ad24e16..063e4b8 100644 --- a/sbin/dmesg/dmesg.c +++ b/sbin/dmesg/dmesg.c @@ -137,9 +137,7 @@ main(int argc, char *argv[]) errx(1, "kvm_read: %s", kvm_geterr(kd)); kvm_close(kd); buflen = cur.msg_size; - bufpos = cur.msg_bufx; - if (bufpos >= buflen) - bufpos = 0; + bufpos = MSGBUF_SEQ_TO_POS(&cur, cur.msg_wseq); } /* -- cgit v1.1