From mboxrd@z Thu Jan 1 00:00:00 1970 From: Philippe Gerum In-Reply-To: References: <1316782850.2050.8.camel@domain.hid> <1316809390.2050.11.camel@domain.hid> <1317034005.2174.6.camel@domain.hid> Content-Type: text/plain; charset="UTF-8" Date: Tue, 04 Oct 2011 17:41:24 +0200 Message-ID: <1317742884.2082.69.camel@domain.hid> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai-help] Xenomai-forge: SEGFAULT is pSOS skin List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ronny Meeus Cc: xenomai-help On Mon, 2011-09-26 at 22:01 +0200, Ronny Meeus wrote: > Next to this I also adapted the task priority automatically using > following algorithm: > static int check_task_priority(u_long *psos_prio) > { > if (*psos_prio < 1 || *psos_prio > 255) /* In theory. */ > return ERR_PRIOR; > /* Do not change priorities <=10 and >= 240. > * Priorities in between are divided by 4 */ > if (*psos_prio > 240) > *psos_prio = 70 + *psos_prio - 240; > else if (*psos_prio > 10) > *psos_prio = 11 + ((*psos_prio-10)/4); > > if ((int)(*psos_prio) >= threadobj_max_prio - 1) /* In practice. */ > panic("current implementation restricts pSOS " > "priority levels to range [1..%d]", > threadobj_max_prio - 2); > > return SUCCESS; > } > > It also works well for our application. > Please share your thoughts. Since we cannot generalize the priority mapping rules, a better way may be to allow your own code to be called by the pSOS emulator when such mapping is required. So I have committed a tentative solution, defining psos_task_normalize_priority() as a weak function, which receives the pSOS priority, and should return the POSIX one. A default implementation is provided by the emulator which does a trivial 1:1 mapping. -- Philippe.