Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 606858 Details for
Bug 851508
Bogus (excessive) /proc/pid/status VmSize,VmmRSS values (& ps output) for threaded processes
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
corrected test case - uncommented comment in first version
thread_experience.c (text/plain), 1.83 KB, created by
paul manser
on 2012-08-24 13:14:08 UTC
(
hide
)
Description:
corrected test case - uncommented comment in first version
Filename:
MIME Type:
Creator:
paul manser
Created:
2012-08-24 13:14:08 UTC
Size:
1.83 KB
patch
obsolete
> >#include <stdio.h> >#include <stdlib.h> >#include <sys/types.h> >#include <pthread.h> > >#define MAX_THREAD 100 >#define GIGABYTE 1024*1024*1024 >/* gcc thread_experience.c -D_REENTRANT -lpthread */ > >pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER; >pthread_cond_t condition_var = PTHREAD_COND_INITIALIZER; > >int gcount; >char *big_ptr; > >typedef struct { > int start,end; >} param; > >void *count(void *arg) { > int i =0; > param *p=(param *)arg; > > big_ptr[100] = p->start; > for(;;) > { > pthread_mutex_lock( &count_mutex ); > pthread_cond_wait( &condition_var, &count_mutex ); > printf(" i = %d ",p->start++); > pthread_mutex_unlock( &count_mutex ); > if(p->start >= p->end) { > printf(" share = %d", big_ptr[100]); > return(NULL); > } > } >} > >int main(int argc, char* argv[]) { > int n,i; > pthread_t *threads; > param *p; > char *big_space; > > if (argc != 2) { > printf ("Usage: %s n\n",argv[0]); > printf ("\twhere n is no. of threads\n"); > exit(1); > } > > n=atoi(argv[1]); > > if ((n < 1) || (n > MAX_THREAD)) { > printf ("arg[1] should be 1 - %d.\n",MAX_THREAD); > exit(1); > } > > threads=(pthread_t *)malloc(n*sizeof(*threads)); > > p=(param *)malloc(sizeof(param)*n); >big_space=(char *)malloc(GIGABYTE*2L); > big_ptr = big_space; > > int *x = malloc(sizeof(int)); > /* Assign args to a struct and start thread */ > for (i=0; i<n; i++) { > p[i].start=i*100; > p[i].end=(i+1)*100; > pthread_create(&threads[i],NULL,count,(void *)(p+i)); > } > printf("\nWait threads\n"); > sleep(1); > > gcount = 0; > for (i=0; i<=100; i++) { > pthread_mutex_lock( &count_mutex ); > gcount++; > pthread_cond_broadcast( &condition_var ); > pthread_mutex_unlock( &count_mutex ); > printf ("master %d \n", i); > sleep(1); > } > > /* Wait for all threads. */ > for (i=0; i<n; i++) { > pthread_join(threads[i],(void*)x); > } > free(p); > exit(0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 851508
:
606839
| 606858