Checking sysctl values from within the kernel.

2005-08-04 Thread Thordur I. Bjornsson
Hello list. If I want to check a sysctl value from within the kernel (e.g. an KLD), should I use the system calls described in sysctl(3) ? If not, what is the propper way to do so ? And if it is and I want to do error checking e.g: if((sysctl(name, namelen, &val, NULL, 0)) != 0) { "Erro

Re: How to do proper locking

2005-08-04 Thread Hans Petter Selasky
On Thursday 04 August 2005 20:15, John Baldwin wrote: > On Thursday 04 August 2005 12:50 pm, Hans Petter Selasky wrote: > > On Thursday 04 August 2005 15:53, John Baldwin wrote: > > > On Thursday 04 August 2005 07:40 am, Hans Petter Selasky wrote: > > > > On Wednesday 03 August 2005 19:21, John Bal

Re: How to do proper locking

2005-08-04 Thread David Malone
On Thu, Aug 04, 2005 at 06:50:12PM +0200, Hans Petter Selasky wrote: > 2) nonblocking: increment some other refcount that the >callback checks before accessing any data. I think people usually call this something like a "generation count". This sort of scheme used to be used for vnodes in Free

Re: How to do proper locking

2005-08-04 Thread John Baldwin
On Thursday 04 August 2005 12:50 pm, Hans Petter Selasky wrote: > On Thursday 04 August 2005 15:53, John Baldwin wrote: > > On Thursday 04 August 2005 07:40 am, Hans Petter Selasky wrote: > > > On Wednesday 03 August 2005 19:21, John Baldwin wrote: > > > > On Tuesday 02 August 2005 06:23 pm, Hans P

Re: How to do proper locking

2005-08-04 Thread Hans Petter Selasky
On Thursday 04 August 2005 15:53, John Baldwin wrote: > On Thursday 04 August 2005 07:40 am, Hans Petter Selasky wrote: > > On Wednesday 03 August 2005 19:21, John Baldwin wrote: > > > On Tuesday 02 August 2005 06:23 pm, Hans Petter Selasky wrote: > > > > Hi, > > > > > > > > I am looking for a safe

Re: How to do proper locking

2005-08-04 Thread Hans Petter Selasky
On Thursday 04 August 2005 14:08, Max Laier wrote: > On Thursday 04 August 2005 13:40, Hans Petter Selasky wrote: > > This is a copy and paste from the kernel sources: > > > > struct ucred * > > crhold(struct ucred *cr) > > { > > The problem is, what happens if the kernel switches thread right here

Re: How to do proper locking

2005-08-04 Thread John Baldwin
On Thursday 04 August 2005 07:40 am, Hans Petter Selasky wrote: > On Wednesday 03 August 2005 19:21, John Baldwin wrote: > > On Tuesday 02 August 2005 06:23 pm, Hans Petter Selasky wrote: > > > Hi, > > > > > > I am looking for a safe way to access structures that can be freed. The > > > solution I

Sub-optimal libc's read-ahead buffering behaviour

2005-08-04 Thread Maxim Sobolev
Hi, I have found the scenario in which our libc behaves utterly suboptimally. Consider the following piece of code reads and processes every other 512-bytes block in a file (error handling intentionally omitted): FILE *f; int i; char buf[512]; f = fopen(...); for (i = 0; feof(f) == 0; i++)

Re: How to do proper locking

2005-08-04 Thread Max Laier
On Thursday 04 August 2005 13:40, Hans Petter Selasky wrote: > This is a copy and paste from the kernel sources: > > struct ucred * > crhold(struct ucred *cr) > { > The problem is, what happens if the kernel switches thread right here, and > then the other thread calls "crfree()" on this structure,

Re: How to do proper locking

2005-08-04 Thread Hans Petter Selasky
On Wednesday 03 August 2005 19:21, John Baldwin wrote: > On Tuesday 02 August 2005 06:23 pm, Hans Petter Selasky wrote: > > Hi, > > > > I am looking for a safe way to access structures that can be freed. The > > solution I am looking for must not: > > > > - hinder scaleability > > - lead to use of

RE: (no subject)

2005-08-04 Thread Felix-KM
>> #define DEVICE2SOFTC(device) ((struct dev_softc >> *)device_get_softc(device)) >> >> static void dev_intr(void *arg); >> >> struct dev_softc { >> ... >> int rid_irq; >> struct resource* res_irq; >> void *intr_cookie; >> ... >> }; >> >> static int >> dev_attach(device_t device) >>

RE: (no subject)

2005-08-04 Thread Norbert Koch
> #define DEVICE2SOFTC(device) ((struct dev_softc > *)device_get_softc(device)) > > static void dev_intr(void *arg); > > struct dev_softc { > ... > int rid_irq; > struct resource* res_irq; > void*intr_cookie; > ... > }; > > static int > dev_attach(device_t device) > { > ... > >

bus_teardown_intr()

2005-08-04 Thread Felix-KM
Sorry, I forgot to indicate the theme. >Hello. >Help me please to understand how the function bus_teardown_intr() works. >I have a device driver containing following code: > >#define DEVICE2SOFTC(device) ((struct dev_softc *)device_get_softc(device)) > >static void dev_intr(void *arg); > >struct de

(no subject)

2005-08-04 Thread Felix-KM
Hello. Help me please to understand how the function bus_teardown_intr() works. I have a device driver containing following code: #define DEVICE2SOFTC(device) ((struct dev_softc *)device_get_softc(device)) static void dev_intr(void *arg); struct dev_softc { ... int rid_irq; struct resource