public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Newbie-Q: Clean exits from tests and examples
@ 2007-05-16 15:05 John Mills
  2007-05-16 18:17 ` Andrew Lunn
  2007-05-16 18:36 ` Sergei Gavrikov
  0 siblings, 2 replies; 4+ messages in thread
From: John Mills @ 2007-05-16 15:05 UTC (permalink / raw)
  To: ecos-discuss

Hello -

I'm getting started with the eCos-2.0 'synthetic' target and have a couple 
of beginner's questions.

I used the command line setup:

$ ecosconfig new linux default

[edited 'ecos.ecc' tools prefix to match my installation]

$ ecosconfig tree
$ make
$ make tests

All this went fine.

I copied the 'ecos-2.0/examples' directory into my scratch directory 
and can built the executables, which also went fine:

$ cd examples
$ make INSTALL_DIR=<my_install>

The 'install/.../tests' like 'wallclock' run and exit fine. The 'examples' 
run fine,
but don't exit (i.e., 'hello' prints its output then sits until I kill it
with '^C').

$ ~/sandbox/ecos/examples> ./hello
Hello, eCos world!
[and here we stay until I issue a '^C']

Question: How should 'examples/hello.c' be structured to run and exit, 
returning cleanly to the parent Linux shell, or how should I invoke it?

Thanks.

 - John Mills
   john.m.mills@alum.mit.edu



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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Newbie-Q: Clean exits from tests and examples
  2007-05-16 15:05 [ECOS] Newbie-Q: Clean exits from tests and examples John Mills
@ 2007-05-16 18:17 ` Andrew Lunn
  2007-05-16 18:36 ` Sergei Gavrikov
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2007-05-16 18:17 UTC (permalink / raw)
  To: John Mills; +Cc: ecos-discuss

On Wed, May 16, 2007 at 09:58:53AM -0500, John Mills wrote:
> Hello -
> 
> I'm getting started with the eCos-2.0 'synthetic' target and have a couple 
> of beginner's questions.
> 
> I used the command line setup:
> 
> $ ecosconfig new linux default
> 
> [edited 'ecos.ecc' tools prefix to match my installation]
> 
> $ ecosconfig tree
> $ make
> $ make tests
> 
> All this went fine.
> 
> I copied the 'ecos-2.0/examples' directory into my scratch directory 
> and can built the executables, which also went fine:
> 
> $ cd examples
> $ make INSTALL_DIR=<my_install>
> 
> The 'install/.../tests' like 'wallclock' run and exit fine. The 'examples' 
> run fine,
> but don't exit (i.e., 'hello' prints its output then sits until I kill it
> with '^C').
> 
> $ ~/sandbox/ecos/examples> ./hello
> Hello, eCos world!
> [and here we stay until I issue a '^C']
> 
> Question: How should 'examples/hello.c' be structured to run and exit, 
> returning cleanly to the parent Linux shell, or how should I invoke it?

Embedded systems don't exit. They run until the power goes off, or
they crash. Hence there is no generic way to exit on eCos.

If you absolutely, really must exit, try calling cyg_hal_sys_exit() on
synth.

   Andrew

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Newbie-Q: Clean exits from tests and examples
  2007-05-16 15:05 [ECOS] Newbie-Q: Clean exits from tests and examples John Mills
  2007-05-16 18:17 ` Andrew Lunn
@ 2007-05-16 18:36 ` Sergei Gavrikov
  2007-05-16 20:42   ` John Mills
  1 sibling, 1 reply; 4+ messages in thread
From: Sergei Gavrikov @ 2007-05-16 18:36 UTC (permalink / raw)
  To: John Mills; +Cc: ecos-discuss

On Wed, May 16, 2007 at 09:58:53AM -0500, John Mills wrote:
> Hello -
> 
> I'm getting started with the eCos-2.0 'synthetic' target and have a couple 
> of beginner's questions.
> 
> I used the command line setup:
> 
> $ ecosconfig new linux default
> 
> [edited 'ecos.ecc' tools prefix to match my installation]
> 
> $ ecosconfig tree
> $ make
> $ make tests
> 
> All this went fine.
> 
> I copied the 'ecos-2.0/examples' directory into my scratch directory 
> and can built the executables, which also went fine:
> 
> $ cd examples
> $ make INSTALL_DIR=<my_install>
> 
> The 'install/.../tests' like 'wallclock' run and exit fine. The 'examples' 
> run fine,
> but don't exit (i.e., 'hello' prints its output then sits until I kill it
> with '^C').
> 
> $ ~/sandbox/ecos/examples> ./hello
> Hello, eCos world!
> [and here we stay until I issue a '^C']
> 
> Question: How should 'examples/hello.c' be structured to run and exit, 
> returning cleanly to the parent Linux shell, or how should I invoke it?
> 

Answer: main(){printf("hello, world!\n");cyg_hal_sys_exit(0);}

That's normal. The _tests_ for the synthetic target usually is finished
by the CYGHWR_TEST_PROGRAM_EXIT (include/cyg/hal/hal_intr.h). So, there
is the cyg_hal_sys_exit(0) in those wallclock* tests.

And you can see that examples/hello.c exits from main with return 0.
That's UNIX way. But eCos != UNIX. Where has to return the application?
You can easy see the difference using GDB, set a breakpoint either to
the 'cyg_test_exit' call (for the tests) or to the 'exit' call (for the
POSIX sources). And more, try to run the synthetic executables from
shell as 'appname --io'.

  Sergei

> Thanks.
> 
>  - John Mills
>    john.m.mills@alum.mit.edu
> 
> 
> 
> -- 
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Newbie-Q: Clean exits from tests and examples
  2007-05-16 18:36 ` Sergei Gavrikov
@ 2007-05-16 20:42   ` John Mills
  0 siblings, 0 replies; 4+ messages in thread
From: John Mills @ 2007-05-16 20:42 UTC (permalink / raw)
  To: ecos-discuss; +Cc: Sergei Gavrikov

Sergei and Andrew -

Thanks for your inputs and excellent explanation. I'm getting somewhat
clearer ideas as I play with the examples.

The context is that I have a moderately complex embedded eCos/MIPS
(mipsisa32-elf-) application and would like to simulate parts of it
multiply and concurrently in a Linux host environment. There is actually
no reason for my simulators to close and exit (other than malfunction)
until I kill them from Linux. In that sense it was a rhetorical question,
but it reflected something basic with eCos that I hadn't thought about.

I wrote a simple script to invoke one instance of the 'twothreads' example 
and log its output to a distinct file, which I could then watch from a 
dedicated xterm using 'tail -f ...':

+++++++++++++++++++++++++++<start_thread.sh>+++++++++++++++++++++++++
#!/bin/sh
proc_no=$$
echo Starting process $proc_no
(./twothreads > threads.$proc_no) &
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

On Wed, 16 May 2007, Sergei Gavrikov wrote:

> On Wed, May 16, 2007 at 09:58:53AM -0500, John Mills wrote:
> > Hello -
> > 
> > I'm getting started with the eCos-2.0 'synthetic' target and have a couple 
> > of beginner's questions.

> > Question: How should 'examples/hello.c' be structured to run and exit, 
> > returning cleanly to the parent Linux shell, or how should I invoke it?
 
> Answer: main(){printf("hello, world!\n");cyg_hal_sys_exit(0);}
 
> That's normal. The _tests_ for the synthetic target usually is finished
> by the CYGHWR_TEST_PROGRAM_EXIT (include/cyg/hal/hal_intr.h). So, there
> is the cyg_hal_sys_exit(0) in those wallclock* tests.
 
> And you can see that examples/hello.c exits from main with return 0.
> That's UNIX way. But eCos != UNIX. Where has to return the application?
> You can easy see the difference using GDB, set a breakpoint either to
> the 'cyg_test_exit' call (for the tests) or to the 'exit' call (for the
> POSIX sources). And more, try to run the synthetic executables from
> shell as 'appname --io'.
 
>   Sergei

 - John Mills
   john.m.mills@alum.mit.edu


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-05-16 18:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-16 15:05 [ECOS] Newbie-Q: Clean exits from tests and examples John Mills
2007-05-16 18:17 ` Andrew Lunn
2007-05-16 18:36 ` Sergei Gavrikov
2007-05-16 20:42   ` John Mills

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).