public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Threads and Handles
@ 2000-07-04  8:21 jens.ohlund
  2000-07-04  8:37 ` Jonathan Larmour
  0 siblings, 1 reply; 4+ messages in thread
From: jens.ohlund @ 2000-07-04  8:21 UTC (permalink / raw)
  To: ecos-discuss

Hi !

I have declared a cyg_handle_t, a cyg_thread and a stack as static.

This thread I start and delete every now and then. In betwen, do I have to do something with the handle ?
Or the memory as well (I'm using the same stack the next time I create the thread).
I mean, the cyg_thread_create sets the cyg_handle_t, but what does it do with the handle if the handle already have some old
values ?

My problem is that after a certain time of create and delete this thread i get a SIGTRAP. And i can't understand why,
because I'm very careful to check that the thread have left OR is in last line of code in the thread method before I delete it.
Just to be sure that resources get back, and by resources I mean memory.

yours
Jens Ohlund


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

* Re: [ECOS] Threads and Handles
  2000-07-04  8:21 [ECOS] Threads and Handles jens.ohlund
@ 2000-07-04  8:37 ` Jonathan Larmour
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Larmour @ 2000-07-04  8:37 UTC (permalink / raw)
  To: jens.ohlund; +Cc: ecos-discuss

jens.ohlund@secrc.abb.se wrote:
> 
> I have declared a cyg_handle_t, a cyg_thread and a stack as static.
> 
> This thread I start and delete every now and then.

Exactly how do you delete it? You may want to read
http://sourceware.cygnus.com/ecos/docs-latest/ref/ecos-ref.9.html#pgfId=1088577

Jifl
-- 
Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS  Tel: +44 (1223) 728762
"Plan to be spontaneous tomorrow."  ||  These opinions are all my own fault

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

* Re: [ECOS] Threads and Handles
  2000-07-04 23:04 jens.ohlund
@ 2000-07-12 17:19 ` Jonathan Larmour
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Larmour @ 2000-07-12 17:19 UTC (permalink / raw)
  To: jens.ohlund; +Cc: ecos-discuss

[ Sorry for the delay - I was away ]

jens.ohlund@secrc.abb.se wrote:
> 
> Deletion of thread:
>        doJVMAgain = FALSE;
>        endJVMLoop = true;
>        while (doJVMAgain == FALSE)
>          cyg_thread_delay(1);
>        while (cyg_thread_delete(threadJVM) == FALSE);
> 
> This is the code the thread is running:
[snip]
> 
>   while (doJVMAgain) {
>     endJVMLoop = false;
[snip]
>   }
> 
>   bindataSize = 0;
>   doJVMAgain = true;
> }

I don't know the priorities of the threads here, but if they are not equal,
the cyg_thread_delete may not do what you expect. You should change that to 

while (cyg_thread_delete(threadJVM) == FALSE)
  cyg_thread_delay(1);

Other than that I can't particularly see what's wrong. Perhaps you would be
best sending the list (not me personally) a small *self-contained* test
case showing the problem. Also tell us your target.

Jifl
-- 
Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS  Tel: +44 (1223) 728762
"Plan to be spontaneous tomorrow."  ||  These opinions are all my own fault

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

* Re: [ECOS] Threads and Handles
@ 2000-07-04 23:04 jens.ohlund
  2000-07-12 17:19 ` Jonathan Larmour
  0 siblings, 1 reply; 4+ messages in thread
From: jens.ohlund @ 2000-07-04 23:04 UTC (permalink / raw)
  To: ecos-discuss

Hi !

Here's the different parts of the specific thread.
Delclarations:
#define STACKSIZE ( CYGNUM_HAL_STACK_SIZE_TYPICAL )
static cyg_handle_t  threadJVM;
static cyg_thread  thread_objJVM;
static char stackJVM[STACKSIZE+2048];

Creation of thread:
      cyg_thread_create(8, jvmTask, (cyg_addrword_t) 0, "JVM",
               (void *)stackJVM, STACKSIZE+2048, &threadJVM, &thread_objJVM);
      cyg_thread_resume(threadJVM);


Deletion of thread:
       doJVMAgain = FALSE;
       endJVMLoop = true;
       while (doJVMAgain == FALSE)
         cyg_thread_delay(1);
       while (cyg_thread_delete(threadJVM) == FALSE);

This is the code the thread is running:
static void jvmTask(CYG_ADDRESS data)
{
  cyg_handle_t jvm_counterH, system_clockH, jvm_alarmH;
  cyg_alarm jvm_alarm;

  // Set upp alarm
  system_clockH = cyg_real_time_clock();
  cyg_clock_to_counter(system_clockH, &jvm_counterH);
  cyg_alarm_create(jvm_counterH, vmTimeSlice_func,
             (cyg_addrword_t) 0,
             &jvm_alarmH, &jvm_alarm);

  // Configure the jvm
  vmconfig.time_slice = TIME_SLICE;
  vmconfig.references = 500;
  vmconfig.strings = 100;
  vmconfig.threads = THREADS;
  vmconfig.app_start = bindata;
  vmconfig.heap_start = jvmHeap;
  vmconfig.heap_end = jvmHeap + HEAP_SIZE;
  vmconfig.timers = TIMERS;
  vmconfig.events = EVENTS_COUNT;
  vmconfig.ev_counters = jvmEvent_counters;
  vmconfig.native_tbl = native_tbl;
  vmconfig.usrNotify = 0;

  while (doJVMAgain) {
    endJVMLoop = false;
    // Wait
    cyg_thread_suspend(threadJVM);

    // Initialize alarm
    // Time is 100 ms between each alarm. 10 ms would be prefered.
    cyg_alarm_initialize(jvm_alarmH, cyg_current_time()+10, 10);

    // Start jvm
    vmStart(&vmconfig);

    // disable alarm
    cyg_alarm_disable(jvm_alarmH);
  }

  bindataSize = 0;
  doJVMAgain = true;
}

endJVMLoop is a variable to control a while loop in the vmStart method.

yours
Jens





ecos-discuss-owner@sourceware.cygnus.com
2000-07-04 17:37


To:   jens.ohlund@secrc.abb.se
cc:   ecos-discuss@sourceware.cygnus.com
Subject:  Re: [ECOS] Threads and Handles

Security Level:?         Internal


jens.ohlund@secrc.abb.se wrote:
>
> I have declared a cyg_handle_t, a cyg_thread and a stack as static.
>
> This thread I start and delete every now and then.

Exactly how do you delete it? You may want to read
http://sourceware.cygnus.com/ecos/docs-latest/ref/ecos-ref.9.html#pgfId=1088577

Jifl
--
Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS  Tel: +44 (1223) 728762
"Plan to be spontaneous tomorrow."  ||  These opinions are all my own fault


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

end of thread, other threads:[~2000-07-12 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-04  8:21 [ECOS] Threads and Handles jens.ohlund
2000-07-04  8:37 ` Jonathan Larmour
2000-07-04 23:04 jens.ohlund
2000-07-12 17:19 ` Jonathan Larmour

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