This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: second post SOS pls. Context switching and loading problem.? for sparc target. Thanks


Dear Nick:
   Firstly thank you very much for your email. But maybe I havn't explained
the question detail and clear enough.
what I meant in Q1 is that: When HAL_THREAD_LOAD_CONTEXT is called in
sched.cxx Cyg_Scheduler::start_cpu()  (**NOT drop through from the
hal_thread_switch_context** then there is no second parameter passed from
the caller, only the stack pointer of the new thread to be excuted passed as
parameter to HAL_THREAD_LOAD_CONTEXT) obviously here hal_thread_load_context
is called without the first part of hal_thread_switch_context being excuted.
So a series of "save" intructions in hal_thread_load_context could save the
register windows set (8) onto the stack but the stack point seems to be lost
after that. (coz the new stack pointer will be loaded in the the stack
pointer register %o6 in later part of hal_thread_load_context)

In Question 2 what I worry about is that if before context switching the
last register window context of new thread to be excuted was located in 4th
register window, if only the last register window is restored back from the
stack to 4th register window, and also CWP points back to 4th register
window, 5th, 6th, 7th are not restored from the stack. Then when the new
thread executes (start from 4th register window) but when it returns to its
caller and CWP set back to 5th register window, but actually 5th register
windows has been restored from the stack of the new thread, **WILL THAT
CAUSE ANY PROBLEM??**

Do you mean the whole register windows set (8) of the new thread will be
restored back from the stack of the new thread in hal_thread_load_thread??
But I just can't figured it out.

Thank you very very much. but still confused

Best regards!

qiang

-----Original Message-----
From: Nick Garnett [mailto:nickg@ecoscentric.com]
Sent: 19 September 2002 14:38
To: Qiang Huang
Cc: Ecos-Discuss
Subject: Re: [ECOS] second post SOS pls. Context switching and loading
problem.? for sparc target. Thanks


"Qiang Huang" <jameshq@liverpool.ac.uk> writes:

> I have asked such simliar question but seems nobody answer me, maybe
because
> of my poor english, so I check the question I post before and revise them
as
> much as I can and write it down as the following. And hope this time I can
> make it as clear as I can make and maybe any expert can help me a little
> bit. Thank you very much.
> (I do believe I still have many unclear english explainings in the
following
> sentence, but may I appologize for that. thank you.)

There are two reasons why you may not be getting many answers. First,
there are very few sparc experts here. Both Gary and I have answered
the questions we can, but neither of us had anything to do with the
original port -- and all we are doing is reading the code and telling
you what it says. Second, your questions are mostly answerable by
reference to the sparc architecture and ABI manuals, they have often
little to do with eCos specifically.


>
> Q1.
> While loading a thread(from very beginning hal_thread_load_context in
> context.S ) why need to save the whole register windows set (8 register
> windows) before loading the thread's context but the %sp is not saved
> anywhere? Isn't the part should be in the hal_thread_switch_context (the
> first part before entering into hal_thread_load_context)??
>

The %sp value is written to [%o1] -- its the second instruction in
hal_thread_switch_context.

>
> Q2.  When switching from a current thread to a new thread why just one
> register window(the last register window) got restored from the stack? How
> about the rest register windows (upper register windows)?  if the last
> register is 4, how about the register windows 8,7,6,5? no need restore??
but
> if return from callee to caller the register window is not the one
expected?
>

We rely on the standard register window save/restore mechanism to do
this. There is no need to load any more than the first window. The
window we restore is that for the caller, the hal_thread_* routines do
not have windows of their own.

I strongly suggest that you read some sparc architecture and ABI
manuals. Everything we do in the sparc HAL is standard stuff explained
there.

--
Nick Garnett - eCos Kernel Architect
http://www.eCosCentric.com/


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]