TOP
SSV Software Systems Register  Register
Log in to check your private messages  Log in to check your private messages
Startseite FAQ Search Mitglieder Profile  Log in 
SSV Support-Forum
posix threads

 
Post new topic   Reply to topic    SSV-Forum Forum Index >>> IGW/900
<<< Previous topic - Next topic >>>  
Display posts from previous:   
Author Message
jwachtel



Joined: 02 Apr 2007
Posts: 3

PostPosted: 24.01.2012, 14:39    Post subject: posix threads Reply with quote

Hallo,
ich möchte threads auf dem IGW/900 verwenden und möchte mein Problem an folgendem code Beispiel demonstrieren:
Code:
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#define NUM_THREADS   5

int finish = 0;

static void* threadFunc(void* arg) {
  pthread_exit(NULL);
}

void leave_loop () {
  finish = 1;
}

int main(int argc, char *argv[])
{
  pthread_t thread;
  int rc;
  long t;
  int i;

  signal (SIGTERM, leave_loop);
  signal (SIGINT, leave_loop);

  while (finish == 0) {

    rc = pthread_create(&thread, NULL, (void*) threadFunc, NULL);
    if (rc){
      printf("ERROR; return code from pthread_create() is %d\n", rc);
      exit(-1);
    }
    rc = pthread_join (thread, NULL);
    fprintf (stderr,"rc == %d\n",rc);
    sleep (1);
  }

  pthread_exit(NULL);
}

Ich kompiliere das Programm mit dem folgenden Befehl
Code:
m68k-elf-gcc -o threads threads.c -lpthread  -Wl,-elf2flt -m5307 -lm -lc

auf einem Ubuntu 10.04 host.
Code:
m68k-elf-gcc --version
liefert
Code:
2.95.3

Wenn ich das Programm auf dem IGW/900 ausführe, werden laufend neue threads generiert aber es bleiben zombie threads zurück und irgendwann können keine neuen Threads mehr erzeugt werden, weil der Speicher ausgeht (
Code:
ERROR; return code from pthread_create() is 11
)
Wenn ich das gleiche Programm mit dem gcc auf meinem Ubuntu Host kompiliere, läuft es einwandfrei, ohne dass Zombieprozesse / -threads zurückbleiben.
Was mache ich falsch oder wie kann ich das Problem umgehen?
Gern können Sie mich telefonisch erreichen unter 076145885425
Mit freundlichem Gruß aus Freiburg,
Jakob Wachtel


--
Dipl.-Ing. (FH) Jakob Wachtel, M.Sc.
Project Manager
Autonomous Systems and Mini-Grids
Department PV Off-Grid Solutions and Battery System Technology
Fraunhofer-Institute for Solar Energy Systems ISE
Heidenhofstrasse 2 | 79110 Freiburg, Germany
Phone: +49 (0) 7 61/ 45 88-5425 | Fax: +49 (0) 7 61/ 45 88-92 17
jakob.wachtel@ise.fraunhofer.de
www.ise.fraunhofer.de
[/quote]
Back to top
View user's profile Send private message
mha



Joined: 05 May 2006
Posts: 28

PostPosted: 27.01.2012, 10:11    Post subject: Reply with quote

Hallo,

unter uClinux sollten Threads nur erstellt und nicht beendet werden, sonst
gibt es Probleme, z.B. Zombie Prozesse, Memleaks, ... .
uClinux und pthread-uClinux ist nicht 100% possix-konform und nur bedingt
einsatzfähig.

Gruß Marco
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SSV-Forum Forum Index >>> IGW/900 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

SSV Software Systems GmbH

Dünenweg 5
30419 Hannover

Fon: +49(0)511  ·  40 000-0
Fax: +49(0)511  ·  40 000-40

sales@ssv-embedded.de


Impressum    ·    Datenschutz    ·    AGB

© 2023 SSV SOFTWARE SYSTEMS GmbH. Alle Rechte vorbehalten.

ISO 9001:2015