From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 10 13:54:56 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 71D5016A401 for ; Mon, 10 Apr 2006 13:54:56 +0000 (UTC) (envelope-from nickolas@atlas.ua) Received: from colt.tsua.net (colt.tsua.net [212.40.34.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8953143D46 for ; Mon, 10 Apr 2006 13:54:54 +0000 (GMT) (envelope-from nickolas@atlas.ua) Received: from localhost (localhost [127.0.0.1]) by colt.tsua.net (Postfix) with ESMTP id 243801050E3 for ; Mon, 10 Apr 2006 16:54:54 +0300 (EEST) Received: from colt.tsua.net ([127.0.0.1]) by localhost (colt.tsua.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05690-07 for ; Mon, 10 Apr 2006 16:54:53 +0300 (EEST) Received: by colt.tsua.net (Postfix, from userid 426) id C0D461050BE; Mon, 10 Apr 2006 16:54:53 +0300 (EEST) Received: from mail.atlas.kiev.ua (atlas-ss-1.tsua.net [212.40.33.65]) by colt.tsua.net (Postfix) with ESMTP id 90F81105082 for ; Mon, 10 Apr 2006 16:54:53 +0300 (EEST) Received: from exim (helo=mail.atlas.kiev.ua) by mail.atlas.kiev.ua with local-smtp (Exim 4.43 (FreeBSD)) id 1FSwwf-0008Ly-EX for freebsd-hackers@freebsd.org; Mon, 10 Apr 2006 17:00:45 +0300 Received: from [172.16.4.222] (helo=dragon60116) by mail.atlas.kiev.ua with esmtp (Exim 4.43 (FreeBSD)) id 1FSwwf-0008Lr-8Z for freebsd-hackers@freebsd.org; Mon, 10 Apr 2006 17:00:45 +0300 Date: Mon, 10 Apr 2006 16:55:11 +0300 From: Nickolas X-Mailer: The Bat! (v3.71.04) UNREG / CD5BF9353B3B7091 Organization: atlas X-Priority: 3 (Normal) Message-ID: <1879959918.20060410165511@atlas.ua> To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at tsua.net Subject: Context switching X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Nickolas List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Apr 2006 13:54:56 -0000 Hello All! I'm porting a CPI card driver from linux to FreeBSD. Some initialization routines require much time (~1-2 seconds). Initialization of hardware should be done during opening device special file. So, I need to switch thread context. I'm doing it in such way: mi_switch(SW_VOL, choosethread()); Main trouble: system panic after program exit. dmesg output: -------------------------- Fatal trap 12: page fault while in user mode fault virtual address = 0xbfbfe5bc fault code = user write, protection violation instruction pointer = 0x1f:0x8074604 stack pointer = 0x2f:0xbfbfe5c0 frame pointer = 0x2f:0xbfbfe5f8 code segment = base 0xc090f8c0, limit 0x0, type 0x13 = DPL 0, pres 1, def32 1, gran 1 processor eflags = interrupt enabled, resume, IOPL = 0 current process = 472 (bash) trap number = 12 panic: page fault -------------------------- Please, tell how correct context switching should be implemented? OS version: FreeBSD 5.4 -- Best regards, Nickolas mailto:nickolas@atlas.ua