From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28282 invoked by alias); 31 Oct 2013 16:25:36 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 28216 invoked by uid 89); 31 Oct 2013 16:25:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SEXUAL_BODY,SPF_HELO_PASS,SPF_PASS autolearn=no version=3.3.2 X-HELO: plane.gmane.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 31 Oct 2013 16:25:34 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Vbv3h-0008Mj-UL for ecos-discuss@ecos.sourceware.org; Thu, 31 Oct 2013 17:25:21 +0100 Received: from dsl.comtrol.com ([64.122.56.22]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 31 Oct 2013 17:25:21 +0100 Received: from grant.b.edwards by dsl.comtrol.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 31 Oct 2013 17:25:21 +0100 To: ecos-discuss@ecos.sourceware.org From: Grant Edwards Date: Thu, 31 Oct 2013 16:25:00 -0000 Message-ID: User-Agent: slrn/1.0.1 (Linux) X-IsSubscribed: yes Subject: [ECOS] How to know if scheduler has started? X-SW-Source: 2013-10/txt/msg00016.txt.bz2 This question has come up many times in the past 10-12 years, but I've never seen a real answer: How do you tell if the scheduler has been started? Specifically, how do you know when it's safe to attempt to lock a mutex? Several people have suggested this snippet: scheduler_running = cyg_thread_self() != cyg_thread_idle_thread(); That seems to work when called from cyg_user_start() and from normal threads, but it doesn't work when called from initialization code in a device driver. So, I'll ask again: how does one write code that knows to lock/unlock a mutex when called from a normal user thread but not attempt the lock/unlock whcn called from initialization code in cyg_user_start() or a device driver? The function does not get called from ISR/DSR contexts: it is only called during initialization (before the scheduler is started) and from normal user threads. OTOH, are you are allowed to lock/unlock mutexes from initialization code? Maybe I'm misremembering, but I thought that was forbidden? -- Grant Edwards grant.b.edwards Yow! I was born in a at Hostess Cupcake factory gmail.com before the sexual revolution! -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss