Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Oct 2000 12:22:19 -0700
From:      Wilbert de Graaf <wilbertdg@hetnet.nl>
To:        freebsd-net@freebsd.org
Subject:   how to lock, but not using spl
Message-ID:  <39DE266B.E9975E2F@hetnet.nl>

next in thread | raw e-mail | index | archive | help


I have been working on some FreeBSD networking code, that used spl() to
protect a linked list. I want to change this using ? so that it would
run on SMP systems too. I monitored the SMP list and had a look in the
4.4BSD book but I haven't been able to find how to do it on BSD. Is
there any sample or can anybopdy give me a pointer ?

- Wilbert


Some more info about what I would like to do:


SLIST_HEAD slh;

// gets called from the ioctl (the api)
void my_ioctl(int n)
{
	struct my_entry e = malloc(sizeof(struct my_entry), ...);
	e->id = n;
	// s = splnet();
	... ? ...
	SLIST_INSERT_HEAD(slh, e, e->link);
	// splx(s);
	... ? ...
}

// gets called from a timer
void my_timer(void)
{
	struct my_entry e;
	FOREACH(e, slh) {
		if (e->done) {
			// s = splnet();
			... ? ...
			SLIST_REMOVE(slh, e, struct my_entry, e->link);
			// splx(s);
			... ? ...
		}
	}
}

I have the impression simple_lock() can do this but I'm not sure if any
of these processes can block on the other. Like what if the net timer
mechanism has to block on a smiple api call.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?39DE266B.E9975E2F>