tasklwIP - A Lightweight TCP/IP stack - Tasks: task #7252, Create sys_thread_new_ex()

 
 

You are not allowed to post comments on this tracker with your current authentication level.

task #7252: Create sys_thread_new_ex()

Submitter:  Bill Florac <bflorac>
Submitted:  Tue 28 Aug 2007 06:04:58 AM UTC
   
 
Category:  None Should Start On:  Tue 28 Aug 2007 12:00:00 AM UTC
Should be Finished on:  Fri 28 Sep 2007 12:00:00 AM UTC Priority:  3 - Low
Status:  None Privacy:  Public
Assigned to:  fbernon Percent Complete:  100%
Open/Closed:  Closed Planned Release:  1.3.0
Effort:  0.00

Jump to the original submission

Wed 05 Sep 2007 04:50:21 PM UTC, comment #13: 

Ok, contrib folder is updated (even "old"). Some @todo are integrated to do some suggestions to port maintainers.

So, I close this task, be reopen if I miss something.

Frédéric Bernon <fbernon>
Group Member
Wed 05 Sep 2007 04:16:21 PM UTC, comment #12: 

Ok, patch is check in, sys_arch.txt is updated. I will update ports this evening.

Frédéric Bernon <fbernon>
Group Member
Wed 05 Sep 2007 02:22:25 PM UTC, comment #11: 

I bow to the consensus!  Fine by me.

Kieran Mansley <kieranm>
Group Member
Tue 04 Sep 2007 06:26:33 PM UTC, comment #10: 

Looks OK..

Bill Florac <bflorac>
Tue 04 Sep 2007 05:18:26 PM UTC, comment #9: 

I will also update sys_arch.txt if it's good.

Frédéric Bernon <fbernon>
Group Member
Tue 04 Sep 2007 05:17:13 PM UTC, comment #8: 

Patch file is attached, based on the current consensus (change directly sys_thread_new). Of course, I don't forget there is also contrib ports to update (but I will do it only when we will check in this one). Comments?

Kieran, about last comments, are you against to include it in 1.3.0?


(file #13877)

Frédéric Bernon <fbernon>
Group Member
Tue 04 Sep 2007 04:12:55 PM UTC, comment #7: 

Just to chip in with my view, since Frederic asked me to on IRC :-).

I would also prefer to change sys_thread_new now, without having sys_thread_new_ex, and preferably before 1.3, due to the incompatibility.

Jonathan Larmour <jifl>
Group Member
Wed 29 Aug 2007 04:30:38 PM UTC, comment #6: 


> perhaps we should simply add these new parameters to current sys_thread_new without adding sys_thread_new_ex.


I would agree to this. Would be nice to have to only have ONE function to write in sys_arch. If a certain architecture cannot/does not use those parameters, the difference is probably only a couple bytes anyway.

Jared Grubb <jgrubb>
Group Member
Wed 29 Aug 2007 04:17:57 PM UTC, comment #5: 


> I'm not in a hurry to get this in for 1.3.0


But, if it HAPPENS to get done in time, that would ok wouldnt it?

Jared Grubb <jgrubb>
Group Member
Wed 29 Aug 2007 08:56:31 AM UTC, comment #4: 

Given that we can do this in a backwardly compatible way, I'm not in a hurry to get this in for 1.3.0, but have no objections to it in the longer term as there is clearly a demand for this.

Kieran Mansley <kieranm>
Group Member
Wed 29 Aug 2007 07:40:42 AM UTC, comment #3: 

For the same reasons than Bill and David, I'm ok with such change, except some details.

I think that TCPIP_THREAD_STACKSIZE should be set to 0 in opt.h (since any other value is system-dependant), same for SLIPIF_THREAD_STACKSIZE and PPP_THREAD_STACKSIZE.

Perhaps we should also define in opt.h DEFAULT_THREAD_NAME="app_thread" and DEFAULT_THREAD_STACKSIZE=0, to be coherent with current other defines of "Thread options" part.

Last, if we do changes in 1.3.0, perhaps we should simply add these  new parameters to current sys_thread_new without adding sys_thread_new_ex. Footprint increase is really small, and ports just have to change the sys_thread_new parameters list to be compatible (and they could continue to do the same thing in their sys_thread_new implementation). More, the change is visible, since they will got error during build.


Frédéric Bernon <fbernon>
Group Member
Tue 28 Aug 2007 10:35:59 PM UTC, comment #2: 

I like this idea. It will map nicely onto my home grown OS's thread creation calls, which expect a process name and stack size.

Stack sizes are a little tricky, as they can vary wildly between platforms. Many platforms would need to specify values in lwipopts.h, and they should at least be listed there in case a new user doesn't notice them in opt.h.

Another approach would be to use representative but arbitrary values in opt.h, and get the implementation of sys_thread_new_ex() to scale them for the platform. This doesn't work well because stack sizes might not scale linearly between two platforms, due to issues like function call depth (more stack frames for one thread vs more local variables for another) and varying stack frame sizes for simple vs complex functions.

David Empson <dempson>
Tue 28 Aug 2007 07:34:56 PM UTC, comment #1: 

Some more details:

Currently, in sys_thread_new(), there is no easy way of knowing what process is being created. In a tightly embedded system, use of resources (RAM) can become critical so it becomes important to only allocate the minimal that is needed for each task. With the current implementation, there are only two ways to track what is being created. Either by counting and hope they get called in the same order or by some global variable. Both of these approaches add unwanted dependencies between modules.

The addition of the name is mostly for debugging purposes. By passing the name on to the OS, we can easily list and separate process problems.

New fuction would look something like:
sys_thread_t sys_thread_new_ex( char* name, void (* thread)(void *arg), void *arg, int stacksize, int prio);

The default values would be defined in opt.h and would be similar to others. For example:

#ifndef TCPIP_THREAD_NAME
#define TCPIP_THREAD_NAME "tcpip_thread"
#endif

#ifndef TCPIP_THREAD_STACKSIZE
#define TCPIP_THREAD_STACKSIZE 10000
#endif

And the old function would be defined as:
#define sys_thread_new(thread, arg, pri) sys_thread_new_ex( NULL, thread, arg, 0, prio)

The three exsting calls are:
sys_thread_new(tcpip_thread, NULL, TCPIP_THREAD_PRIO);
sys_thread_new(slipif_loop, netif, SLIPIF_THREAD_PRIO);
sys_thread_new(pppMain, (void*)pd, PPP_THREAD_PRIO);


Bill Florac <bflorac>
Tue 28 Aug 2007 06:04:58 AM UTC, original submission:  

Create a new extended function, sys_thread_new_ex() with addional parameters.

The three existing calls in lwip would be modified to use the new funciton with parameters as set in opt.h.

New function would add 2 additional parameters:
1) name = char* that points to the task name. NULL if not assigned (or assigned in sys_arch.c/OS)

2) stack_size = unsigned integer indicating the desired stack size. This may be used in sys_arch.c.  A value of 0 would indicate "minimal" as set by the OS.

Existing sys_thread_new() would be defined as a macro that calls the new function with values NULL and 0 respectively making it backward compatible.

Bill Florac <bflorac>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #13877:  sys_thread_new.patch added by fbernon (5KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jifl (Posted a comment)
  • -email is unavailable- added by jgrubb (Posted a comment)
  • -email is unavailable- added by kieranm (Posted a comment)
  • -email is unavailable- added by fbernon (Posted a comment)
  • -email is unavailable- added by dempson (Posted a comment)
  • -email is unavailable- added by bflorac (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-09-05 fbernon Percent Complete50% 100%
        Open/ClosedOpen Closed
    2007-09-05 kieranm Planned ReleaseNone 1.3.0
    2007-09-04 fbernon Attached File- Added sys_thread_new.patch, #13877
        Percent Complete0% 50%
        Assigned toNone fbernon
    2007-08-29 kieranm Priority5 - Normal 3 - Low

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code