Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932749AbbHJUw5 (ORCPT ); Mon, 10 Aug 2015 16:52:57 -0400 Received: from smtprelay05.ispgateway.de ([80.67.18.28]:48293 "EHLO smtprelay05.ispgateway.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932553AbbHJUw4 (ORCPT ); Mon, 10 Aug 2015 16:52:56 -0400 X-Greylist: delayed 316 seconds by postgrey-1.27 at vger.kernel.org; Mon, 10 Aug 2015 16:52:55 EDT Message-ID: <55C90DE7.1000400@riesch.at> Date: Mon, 10 Aug 2015 22:47:35 +0200 From: Michael Riesch User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org CC: j.lelli@sssup.it Subject: Question about SCHED_DEADLINE and sched_yield() usage Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Df-Sender: bWljaGFlbEByaWVzY2guYXQ= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1514 Lines: 43 Hi all, I connected two analog-to-digital converters to a BeagleBoneBlack (with kernel version 3.14.33-ti-r51.2) and tried to use the deadline scheduler to get samples at a constant rate. In my C++/Qt application the ADCs are represented by a class which is derived from QThread. The run() method is basically: run() { unsigned int flags; struct sched_attr attr; attr.sched_policy = SCHED_DEADLINE; attr.sched_runtime = 600 * 1000; attr.sched_deadline = 1250 * 1000; attr.sched_period = 1250 * 1000; sched_setattr(0, &attr, flags); while (active) { /* code that gets a sample from adc, takes around 500 ms */ sched_yield(); } } to get samples at a rate of 800 Hz. However, once sched_yield() is called, the threads do not seem to be scheduled again (no samples are acquired and when the application shuts down the threads remain as zombies). As far as I understand, I have to call sched_yield() if the the execution time of one loop iteration is either not constant or unknown (both cases being very likely), because if I do not, a new loop iteration could be started if the time budget is not empty. Have I missed something? Any ideas or alternative approaches are welcome! Thanks a lot in advance! Best regards, Michael -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/