From: Arjen M. <Arj...@de...> - 2015-01-26 08:14:37
|
Hi Sergei, I took example x00 and turned it into a multithreaded version. It worked as you would expect - the picture is drawn correctly in the separate thread, no problems there. It would seem that there is more to it than "merely" a multithreaded environment. Could you try this code and see what happens in your environment? Regards, Arjen ---- // Simple demo of a 2D line plot. // // Copyright (C) 2011 Alan W. Irwin // // This file is part of PLplot. // // PLplot is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License as published // by the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // PLplot is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with PLplot; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // // #include <pthread.h> #include "plcdemos.h" #define NSIZE 101 typedef struct { PLFLT *x; PLFLT *y; } thread_data; void *thread_start( void *arg ) { thread_data *pdata = arg; plline( NSIZE, pdata->x, pdata->y ); return NULL; } int main( int argc, const char *argv[] ) { PLFLT x[NSIZE], y[NSIZE]; PLFLT xmin = 0., xmax = 1., ymin = 0., ymax = 100.; int i; pthread_t tid; thread_data data; void *res; // Prepare data to be plotted. for ( i = 0; i < NSIZE; i++ ) { x[i] = (PLFLT) ( i ) / (PLFLT) ( NSIZE - 1 ); y[i] = ymax * x[i] * x[i]; } // Parse and process command line arguments plparseopts( &argc, argv, PL_PARSE_FULL ); // Initialize plplot plinit(); // Create a labelled box to hold the plot. plenv( xmin, xmax, ymin, ymax, 0, 0 ); pllab( "x", "y=100 x#u2#d", "Simple PLplot demo of a 2D line plot" ); // Plot the data that was prepared above. data.x = x; data.y = y; pthread_create( &tid, NULL, thread_start, &data ); //plline( NSIZE, x, y ); // Close PLplot library pthread_join( tid, &res ); plend(); exit( 0 ); } DISCLAIMER: This message is intended exclusively for the addressee(s) and may contain confidential and privileged information. If you are not the intended recipient please notify the sender immediately and destroy this message. Unauthorized use, disclosure or copying of this message is strictly prohibited. The foundation 'Stichting Deltares', which has its seat at Delft, The Netherlands, Commercial Registration Number 41146461, is not liable in any way whatsoever for consequences and/or damages resulting from the improper, incomplete and untimely dispatch, receipt and/or content of this e-mail. |