From: mea@sparta.com (Mike Anderson)
Newsgroups: comp.os.vxworks
Subject: re:  comp.os.vxworks newsdigest
Date: Sun, 12 Apr 92 14:47:42 EDT
Organization: Lawrence Berkeley Laboratory, Berkeley CA
NNTP-Posting-Host: 128.3.112.16
Originator: daemon@vxw.ee.lbl.gov

Greetings!

----- Begin Included Message -----

From: paulg@tplrd.tpl.oz.au (Paul Gittings)
Organization: Telectronics Pacing Systems


This is a beginners question and I apologize in advance if I've wasted
bandwidth by asking for information which I should have been able to find 
in the manual (I did look, Honest).

Are there any major differences in a tasks environment when it is run
from the shell:

   -> main

to when it is spawned off using "sp" ?:

   -> sp main


We have vxWorks 5.0.2 and our target is National Instruments  VXIcpu030.

Cheers,
Paul Gittings

----- End Included Message -----

Well, first there was a syntax error in the code:

sd = socket(PF_INET,SOCK_STREAM,0);

should have been

sd = socket(AF_INET,SOCK_STREAM,0);

but that's not what's causing your problems.  The differences you're
experiencing are a result of the context your main is executing in.
When you run main from the shell, "main" runs as a subroutine within
the shell task's context and as such uses the shell task's stack.

-> main

    |---------------Shell Task---------------|
    |                             |----------|
    |          |----------|       | Stack    |
    |          |  main    |       |----------|
    |          |----------|                  |
    |----------------------------------------|

But, when you use "sp", "main" becomes a separate task and uses a
new stack whose size is determined by the parameters to "sp" as
defined in <vxWorks-dir>/config/all/usrLib.c.

-> sp main

    |---------------Shell Task---------------|   |------ main task -----|
    |                             |----------|   |              |-------|
    |                             | Stack    |   |              | Stack |
    |                             |----------|   |              |-------|
    |                                        |   |----------------------|
    |----------------------------------------|

To set it up so main has the same stack size as the shell task, either
use taskSpawn and explicitly fill in the stack size or modify the 
stack size parameter in usrLib.c when sp calls taskSpawn to actually
spawn the task.  Remember that "sp" is really just a front end for
taskSpawn that fills some of the pieces for you.  You can check the 
current stack parameters for a given task using checkStack.  Also,
anytime you use NFS in any of your tasks, be sure to have at least a 7K
stack and preferably more like 10K if you expect your code to avoid
stack crashes.

Good luck,


==============================================================================
    AAAA  D D    D D    EEEEE   M   M  TM  // AAAA RRRR  TTTTTT SSSSS EEEEE TM
   A   A  D   D  D   D  E      M M M M    // A   A R   R   TT   S     E
  AAAAAA  D   D  D   D  EEEEE  M  M  M   // AAAAAA RRRR    TT    SSS  EEEEE
 A     A  D   D  D   D  E      M     M  // A     A R  R    TT       S E
A      A  D D    D D    EEEEE  M     M // A      A R   R   TT   SSSSS EEEEE

Process Distribution/Control and Communications for Distributed Systems

Mike Anderson                       Voice: (703) 448-0210 ext. 235
Director, ADDEM(TM) Project Office  FAX:   (703) 734-3323
SPARTA, Inc.                        EMAIL: mea@sparta.com
Suite 900                     
7926 Jones Branch Drive        "The optimist proclaims that we live in the
McLean, VA  22102               best of all possible worlds, and the pessimist
                                fears that this is true."

                                    J.B. Cabell

==============================================================================



Newsgroups: comp.os.vxworks