public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Hugo 'NOx' Tyson <hmtx@redxhatx.com>
To: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] cyg_scheduler_lock
Date: Wed, 23 May 2001 10:45:00 -0000	[thread overview]
Message-ID: <wwtpud0ge3q.fsf@masala.cambridge.redhat.com> (raw)
In-Reply-To: <3B0BD36B.7F6BE5A@tid.es>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]


Rafael Rodríguez Velilla <rrv@tid.es> writes:

>   I'm reading "eCos Reference Manual" and I see that
> cyg_scheduler_lock.
>    Locks the scheduler so that a context switch cannot occur. This can
> be used to protect data shared between a thread and a DSR, or between
> multiple threads, by surronding the critical region with
> cyg_scheduler_lock() and cyg_scheduler_unlock().
> 
> I don't understand that of protecting data between DSRs and threads?
> 
>   If I lock the scheduler during the thread then no DSR can occur, no
> other thread can gain the CPU.

Correct.

The flip side of this is that a DSR can only run (and do things that might
modify kernel variables) when the thread is *not* doing things that modify
kernel variables.

>   Is it safe to use cyg_scheduler_lock or unlock inside a DSR?

DSRs are executed with the scheduler already locked.  That's why DSRs may
only perform producer operations (signal, send, wakeup, setflag) and must
not sleep (get, wait, delay).

Making calls to lock and unlock the scheduler within a DSR is therefore
pointless - but you can call code that does that if you want to share a
routine between the task and the DSR, so long as it counts up (locks) the
same number as it counts down (unlocks).

Performing producer operations does indeed increment and decrement the
scheduler lock, but it must not become unlocked (==0) within the execution
of a DSR.

	- Huge

      parent reply	other threads:[~2001-05-23 10:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-23  9:41 Rafael Rodríguez Velilla
2001-05-23 10:31 ` Jonathan Larmour
2001-05-23 10:53   ` Rafael Rodríguez Velilla
2001-05-23 11:38     ` Jonathan Larmour
2001-05-24  4:55       ` Rafael Rodríguez Velilla
2001-05-24  5:49         ` Hugo Tyson
2001-05-23 10:45 ` Hugo 'NOx' Tyson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wwtpud0ge3q.fsf@masala.cambridge.redhat.com \
    --to=hmtx@redxhatx.com \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).