From owner-freebsd-current@FreeBSD.ORG Thu Sep 30 07:06:49 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA3D216A4CE for ; Thu, 30 Sep 2004 07:06:49 +0000 (GMT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5389E43D1D for ; Thu, 30 Sep 2004 07:06:49 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.13.1/8.13.1) with ESMTP id i8U76ldP037649 for ; Thu, 30 Sep 2004 09:06:47 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: current@freebsd.org Date: Thu, 30 Sep 2004 09:06:47 +0200 Message-ID: <37648.1096528007@critter.freebsd.dk> From: Poul-Henning Kamp X-Mailman-Approved-At: Thu, 30 Sep 2004 11:55:21 +0000 Subject: Unit number allocation API X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2004 07:06:50 -0000 I had this one out on arch@ previously. I'm very interested in informed feedback on how we deal with locking for service api's like this. Poul-Henning phk 2004-09-30 07:04:03 UTC FreeBSD src repository Modified files: sys/sys systm.h sys/conf files Added files: sys/kern subr_unit.c Log: Add a new API for allocating unit number (-like) resources. Allocation is always lowest free unit number. A mixed range/bitmap strategy for maximum memory efficiency. In the typical case where no unit numbers are freed total memory usage is 56 bytes on i386. malloc is called M_WAITOK but no locking is provided (yet). A bit of experience will be necessary to determine the best strategy. Hopefully a "caller provides locking" strategy can be maintained, but that may require use of M_NOWAIT allocation and failure handling. A userland test driver is included. Revision Changes Path 1.955 +1 -0 src/sys/conf/files 1.1 +597 -0 src/sys/kern/subr_unit.c (new) 1.215 +8 -0 src/sys/sys/systm.h ------- End of Forwarded Message