From mboxrd@z Thu Jan 1 00:00:00 1970 References: <87zh1qqpkp.fsf@xenomai.org> From: Philippe Gerum Subject: Re: domain switch In-reply-to: Date: Sun, 03 Jan 2021 12:06:37 +0100 Message-ID: <87v9ceqnya.fsf@xenomai.org> MIME-Version: 1.0 Content-Type: text/plain List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Leandro Bucci Cc: steve freyder , xenomai@xenomai.org Leandro Bucci writes: > is it possible to have the same thing for tasks instead of threads? > task == thread > Il dom 3 gen 2021, 11:31 Philippe Gerum ha scritto: > >> >> steve freyder via Xenomai writes: >> >> > Right. >> > >> > >> > AKA, "mode switch", a switch from "primary mode" to "secondary mode", >> > or vice versa. >> > >> > One place you can find that information is in: >> > >> > /proc/xenomai/sched/acct >> > >> > there are two fields MSW, and CSW which count mode/context switches >> > per-process. This requires an open, a read loop to locate the desired >> > pid and extract the desired information, then either rewind or >> > close/reopen to do it again - all of which will almost surely generate >> > more mode/context switching. >> > >> >> If that helps, there is also the option of getting the thread stats by >> program, using int cobalt_thread_stat(pid_t pid, struct >> cobalt_threadstat *stat), declared in sys/cobalt.h. pid refers to a >> thread identifier (as obtained from gettid(2) in the context of the >> target thread). It must refer to a Cobalt thread, otherwise the call >> would fail with -ESRCH. >> >> The mode switch count is present in the returned information block >> (->msw). cobalt_thread_stat() would not cause any mode switch. It can be >> called by any thread regardless of its type (i.e. regular or Cobalt). >> >> -- >> Philippe. >> -- Philippe.