From: Bart Veer <bartv@cygnus.co.uk>
To: gorlick@aero.org
Cc: ecos-discuss@cygnus.com
Subject: Re: [ECOS] Preemptive Scheduling in Multilevel Queue Scheduler
Date: Fri, 11 Dec 1998 06:51:00 -0000 [thread overview]
Message-ID: <199812111243.MAA19463@sheesh.cygnus.co.uk> (raw)
In-Reply-To: < l03110714b295f219cd51@[130.221.199.187] > (message from MichaelGorlick on Thu, 10 Dec 1998 13:49:48 -0800)
>>>>> "Michael" == Michael Gorlick <gorlick@aero.org> writes:
Michael> Will someone please straighten me out? After staring at
Michael> the eCos source code it just isn't clear to me how
Michael> preemptive (timesliced) scheduling actually works in the
Michael> multilevel queue scheduler (mlqueue).
Michael> The expiration of a timeslice results in a DSR being
Michael> posted on the DSR queue and that DSR, when executed,
Michael> forces the current thread to relinquish the processor (by
Michael> invoking "yield()" on the current thread). However (and
Michael> this is where my confusion arises) DSRs are executed
Michael> when, and only when, the scheduler lock is about to
Michael> transition from 1 to 0. Consequently, if a thread running
Michael> under the multilevel queue discipline NEVER directly or
Michael> indirectly invokes the scheduler "unlock()" method no
Michael> DSRs will ever be executed and the thread will never be
Michael> forced to yield the processor irrespective of the number
Michael> of timeslices periods that have passed. Is this correct
Michael> and if not where should I look in the source code to
Michael> correct my misunderstanding?
Michael> The same problem exists for DSRs in general since
Michael> "unlock_inner" is the only component (as far as I can
Michael> determine) that calls and executes the posted DSRs.
Michael> Again, how do device drivers and interrupts get their
Michael> DSRs executed in a timely manner if their execution can
Michael> be delayed indefinitely by a thread that, for whatever
Michael> reason, never acquires or releases the scheduler lock?
The missing piece in the puzzle is the routine interrupt_end() in
kernel/v1.1/src/intr/intr.cxx. This gets invoked at the end of ISR
interrupt handling, and includes a call to Cyg_Scheduler::unlock().
If an interrupt happens when the foreground application was executing
ordinary code, and a resulting DSR has invoked yield(), this call to
unlock() will result in a context switch at the end of interrupt
handling. If the foreground application was in a critical section at
the time that the interrupt occurred then the scheduler will be
locked, the interrupt handler will return to the current thread, and
the context switch happens when the thread leaves its critical section
and unlocks the scheduler.
Bart Veer // eCos net maintainer
next prev parent reply other threads:[~1998-12-11 6:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-12-10 13:48 Michael Gorlick
[not found] ` < l03110714b295f219cd51@[130.221.199.187] >
1998-12-11 6:51 ` Bart Veer [this message]
[not found] <l03110714b295f219cd51.cygnus.sourceware.ecos.d@[130.221.199.187]>
1998-12-11 6:51 ` Nick Garnett
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=199812111243.MAA19463@sheesh.cygnus.co.uk \
--to=bartv@cygnus.co.uk \
--cc=ecos-discuss@cygnus.com \
--cc=gorlick@aero.org \
/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).