Hi,
On Tue, 2014-11-11 at 16:08 +0100, Cyril Hrubis wrote:
> Hi!
...
> > if (debug)
> > - printf("Thread [main] checksum: %-#12lx \n", checksum);
> > + printf("\tThread [main] checksum: %-#12lx\n", checksum);
>
> What is the use for the '\t' here? As far as I can see the printed
> strings in the testcase ends up with '\n' anyway and so the printed
> statement starts at first column anyway.
>
I just want to delete the whitespace before the quoted, and add '\t'.
OK, I will not add '\t'.
> > if (pthread_attr_init(&attr))
> > sys_error("pthread_attr_init failed", __LINE__);
> > if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE))
> > sys_error("pthread_attr_setdetachstate failed", __LINE__);
> >
> > - /* Create num_thread threads... */
> > - printf("\tThread [main] Creating %d threads\n", num_threads);
> > + printf("Thread [main] Creating %d threads\n", num_threads);
> >
> > array = malloc(sizeof(pthread_t) * num_threads);
> > arg = malloc(sizeof(int) * num_threads);
>
> Can we also get rid of allocations and decleare the arrays as:
>
> pthread_t array[num_threads];
>
> instead?
>
OK, I will use the arrays. :)
> > @@ -126,15 +83,15 @@ int main(int argc, char **argv)
> > if (debug)
> > printf("\tThread [main]: creating thread %d\n", i + 1);
> > arg[i] = i + 1;
> > - if (pthread_create
> > - ((pthread_t *) & array[i], &attr, (void *)thread,
> > - (void *)&arg[i])) {
> > - if (errno == EAGAIN)
> > + if (pthread_create((pthread_t *)&array[i], &attr,
> > + (void *)thread, (void *)&arg[i])) {
> > + if (errno == EAGAIN) {
> > fprintf(stderr,
> > - "\tThread [main]: unable to create
> > thread %d\n",
> > - i);
> > - else
> > + "\tThread [main]: unable to create "
> > + "thread %d\n", i);
> > + } else {
> > sys_error("pthread_create failed", __LINE__);
> > + }
> > }
> > if (debug)
> > printf("\tThread [main]: created thread %d\n", i + 1);
> > @@ -144,8 +101,7 @@ int main(int argc, char **argv)
> >
> > for (i = 0; i < num_threads; i++) {
> > void *exit_value;
> > - printf("\tThread [main]: waiting for thread: %d\n", i + 1);
> > - /*if (pthread_join ((pthread_t*) array [i], (void **)
> > &exit_value)) */
> > + printf("Thread [main]: waiting for thread: %d\n", i + 1);
> > if (pthread_join(array[i], &exit_value))
> > sys_error("pthread_join failed", __LINE__);
> >
> > @@ -157,25 +113,16 @@ int main(int argc, char **argv)
> > free(array);
> > free(arg);
>
> ...
>
> > - /* One or more of the threads did not complete sucessfully! */
> > if (rc != 0) {
> > printf("test failed!\n");
> > exit(-1);
> > + } else {
> > + printf("Thread [main] All threads completed successfully...\n");
> > + exit(0);
> > }
> > -
> > - /* Program completed successfully... */
> > - printf("\tThread [main] All threads completed successfully...\n");
> > - exit(0);
>
> There is no need for this particular change.
>
> If we enter the if block we will exit at exit(-1) otherwise we continue
> to the end of the function.
>
OK, I will not changed it.
And thank you very much.
Best regards,
Zeng
------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list