text stringlengths 192 6.24k | label int64 0 1 |
|---|---|
#include <pthread.h>
unsigned short ADPAL[256];
static char pathbuf[4096];
int isIphone5;
void *_psg;
static void *_spu;
static pthread_mutex_t lckobj = PTHREAD_MUTEX_INITIALIZER;
extern struct VgsKeyInfo _vgskey;
int vgsint_init(const char *rompath)
{
char log[1024];
sta... | 1 |
#include <pthread.h>
{
pthread_mutex_t mutex;
struct timespec *queue;
int s_queue;
int i_queue;
int n_queue;
pthread_cond_t not_empty;
pthread_cond_t not_full;
int max_send;
int n_sent;
} queue_t;
{
queue_t *queue;
int id;
pthread_t pid;
} args_t;
void *sender(void *arg... | 0 |
#include <pthread.h>
static pthread_mutex_t m_trace = PTHREAD_MUTEX_INITIALIZER;
void output_init()
{
return;
}
void output( char * string, ... )
{
va_list ap;
char *ts="[??:??:??]";
struct tm * now;
time_t nw;
pthread_mutex_lock(&m_trace);
nw = time(0);
now = localt... | 1 |
#include <pthread.h>
pthread_mutex_t count_lock;
pthread_cond_t count_nonzero;
unsigned count = 0;
void * decrement_count(void *arg){
while(1){
pthread_mutex_lock(&count_lock);
printf("decrement_count get count_lock ^-^-%d-^-^\\n", count);
while (count == 0){
... | 0 |
#include <pthread.h>
struct node *head = 0;
struct node *create_node(int value) {
struct node *newnode = malloc(sizeof(struct node));
newnode->value = value;
newnode->next = 0;
return newnode;
}
void insert(struct list *L, int value){
struct node *newnode = create_node(value... | 1 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_cond_t cond;
pthread_t thread;
unsigned data;
unsigned acks;
unsigned tests_total, tests_failed;
bool done;
void report(const char* name, bool passed)
{
static const char* status[] = { "FAIL", "PASS" };
printf("%s: %s\\n", status... | 0 |
#include <pthread.h>
void initEventQueue(){
pthread_mutex_init(&SlicEvntQueueLenMutex, 0);
pthread_mutex_lock (&SlicEvntQueueLenMutex);
struct SlicEvntQueue *tmp = (struct SlicEvntQueue*)malloc(sizeof(struct SlicEvntQueue));
SlicEvntQueueLen = 0;
HeadSlicEvntQueue = tmp;
EndSlicEvntQueue = ... | 1 |
#include <pthread.h>
long i, N, paralelism;
long double timetick;
long *vector;
long debug = 0, power;
struct My_threads {
long init;
long fin;
pthread_t thread;
int id;
};
struct My_threads *p_threads;
pthread_mutex_t count_lock;
pthread_cond_t ok_to_proceed;
int count;
} mylib_barrie... | 0 |
#include <pthread.h>
pthread_cond_t cond;
pthread_mutex_t mutex;
void* p_func(void* p)
{
pthread_mutex_lock(&mutex);
int ret;
int i=( int)p;
printf(" i am child %d,this is wait entrance\\n",i );
ret=pthread_cond_wait(&cond,&mutex);
if(0!=ret)
{
printf("pthread_cond_wait ret is %... | 1 |
#include <pthread.h>
int a[8];
int b[8];
int c[4];
pthread_t mc[4];
pthread_t display;
pthread_mutex_t mc_lock[4] =
{
PTHREAD_MUTEX_INITIALIZER,
PTHREAD_MUTEX_INITIALIZER,
PTHREAD_MUTEX_INITIALIZER,
PTHREAD_MUTEX_INITIALIZER
};
void *thr_mc(void *arg)
{
printf("MC%d: tid %u\\n", ... | 0 |
#include <pthread.h>
long int c1,c2,c3,c4;
pthread_mutex_t m1,m2,m3,m4;
void * th1(void * p)
{
long int i,j,n;
pthread_mutex_lock(&m1);
for(n=3;n<=4000000;n+=2)
{
j=sqrt(n);
for(i=2;i<=j+1;i++)
if(n%i==0)
break;
if(i>=j)
{
c1++;
printf("%ld\\n",n);
}
}
pthread_mutex_unlock(&m1)... | 1 |
#include <pthread.h>
void
diskfs_nrele (struct node *np)
{
int locked = FALSE;
struct references result;
refcounts_demote (&np->refcounts, &result);
if (result.hard == 0)
{
locked = TRUE;
pthread_mutex_lock (&np->lock);
diskfs_lost_hardrefs (np);
if (!... | 0 |
#include <pthread.h>
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER, cond_baby = PTHREAD_COND_INITIALIZER;
int finish = 0;
int foodbits = 0;
struct checkerarg {
int f;
long r;
int *working;
int *eating;
pthread_mutex_t *mut;
};
struct paren... | 1 |
#include <pthread.h>
int mediafirefs_setxattr(const char *path, const char *name,
const char *value, size_t size, int flags)
{
printf("FUNCTION: setxattr. path: %s\\n", path);
(void)path;
(void)name;
(void)value;
(void)size;
(void)flags;
st... | 0 |
#include <pthread.h>
struct list_node **head_p;
struct argument_list arguments;
pthread_mutex_t lock;
struct list_node
{
int data;
struct list_node* next;
};
struct argument_list {
int m;
float mOps[3];
struct list_node** head_p;
int threads;
};
int member(int value, struct ... | 1 |
#include <pthread.h>
void
ports_enable_bucket (struct port_bucket *bucket)
{
pthread_mutex_lock (&_ports_lock);
bucket->flags &= ~PORT_BUCKET_NO_ALLOC;
if (bucket->flags & PORT_BUCKET_ALLOC_WAIT)
{
bucket->flags &= ~PORT_BUCKET_ALLOC_WAIT;
pthread_cond_broadcast (&_ports_bloc... | 0 |
#include <pthread.h>
struct wonk{
int a;
} *shrdPtr, *symb_shrdPtr;
pthread_mutex_t lock;
struct wonk *getNewVal(struct wonk**old){
*old = 0;
struct wonk *newval = (struct wonk*)malloc(sizeof(struct wonk));
newval->a = 1;
return newval;
}
void *updaterThread(void *arg){
... | 1 |
#include <pthread.h>
int sock;
struct sockaddr_in servAddr;
int port;
char *ipAddr;
char parametersList[1024];
uint32_t key[4] = { 31231234, 412334, 12341, 657657 };
pthread_mutex_t lock;
char *event = 0;
suseconds_t lastUpdate = 0;
struct per_session_data__event {
suseconds_t timeOf... | 0 |
#include <pthread.h>
struct thread_data{
char *str1;
char *str2;
};
int total = 0;
int n1,n2;
char *s1,*s2;
FILE *fp;
pthread_mutex_t mutexsum;
volatile int running_threads = 0;
int readf(FILE *fp)
{
if((fp=fopen("strings.txt", "r"))==0){
printf("ERROR: can't open message.txt!... | 1 |
#include <pthread.h>
double integral = 0.0;
pthread_mutex_t soma;
{
double a;
double b;
int N;
} Targumentos;
double AreaTrapezio(double dx, double h1, double h2)
{
return (dx*(h1+h2)/2);
}
double f(double x)
{
return (4*sqrt(1-x*x));
}
void ThreadCalculaArea(Targumentos *ar... | 0 |
#include <pthread.h>
size_t size;
size_t align;
union {
uintptr_t index;
void* address;
} object;
void* value;
} __emutls_control;
static inline void* emutls_memalign_alloc(size_t align, size_t size) {
void *base;
char* object;
if ((object = ma... | 1 |
#include <pthread.h>
static void alarm_handler(int signo);
static void *logger_start(void *arg);
static struct {
int curr;
char log[MAX_LOG_ENTRY][MAX_STRING_LENGTH];
pthread_mutex_t mutex;
} buff;
void init_buffer()
{
printf("RING BUFFER: Initializing the ring buffer\\n");
... | 0 |
#include <pthread.h>
uint32_t counter;
pthread_t threads[2];
pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t _start = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t _cond = PTHREAD_COND_INITIALIZER;
void *thread_function (void *thread_data) {
pthread_mutex_lock(&_start);
... | 1 |
#include <pthread.h>
struct screen_in_t {
int up, down, left, right;
int a;
};
struct screen_tty_t {
const struct screen_ops_t *ops;
pthread_t thread;
struct {
pthread_mutex_t mutex;
pthread_cond_t cond;
int ev;
} event;
struct map_t map;
struct screen_in_t i... | 0 |
#include <pthread.h>
const int capacity = 100;
const int round_max = 50000;
int capacity;
int size;
item_t* space;
pthread_mutex_t lock;
pthread_cond_t some_space;
pthread_cond_t some_items;
} storage_t;
void* produce(void* param) {
storage_t* storage = (storage_t*) param;
... | 1 |
#include <pthread.h>
pthread_mutex_t mutex;
void* thread(void* p)
{
int *q=(int*)p;
int i;
for(i=0;i<10000000;i++)
{
pthread_mutex_lock(&mutex);
*q+=1;
pthread_mutex_unlock(&mutex);
}
printf("the thread %d creat success,\\n",*q);
return 0;
}
int main()
{
pthread_t id;
int i,ret;
... | 0 |
#include <pthread.h>
int G_CHUNK_SIZE;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
large_uint G_current_start;
large_uint G_subset_count;
int G_terminated_flag;
large_uint G_steps;
void increment_step() {
pthread_mutex_lock(&mutex);
G_steps++;
pthread_mutex_unlock(&mutex);
}
struct s... | 1 |
#include <pthread.h>
void *heartbeater(void);
void timer_handler(void);
void setup_timer(void);
int *old_seq;
int *new_seq;
int seq_size;
int sequence_num;
pthread_t heartbeat_thread;
pthread_mutex_t suspend_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t suspend_cond = PTHREAD_COND_INITIAL... | 0 |
#include <pthread.h>
sem_t tob_paper;
sem_t match_paper;
sem_t tob_match;
pthread_mutex_t table_mutex;
pthread_cond_t condition_var;
void serve_tob_paper();
void serve_match_paper();
void serve_tob_match();
void consumer_tob_paper();
void consumer_match_paper();
void consumer_tob_match();
... | 1 |
#include <pthread.h>
unsigned int TEST_TMP;
unsigned int TEST_VALUE_CA[8][3] = {
{CMD_READ, REG_MC34704_GENERAL1, &TEST_TMP},
{CMD_SUB, 2, 0},
{CMD_READ, REG_MC34704_GENERAL2, &TEST_TMP},
{CMD_SUB, 0, 0},
{CMD_READ, REG_MC34704_FAULTS, &TEST_TMP},
{CMD_UNSUB, 0, 0},
{CMD_UNSUB, ... | 0 |
#include <pthread.h>
int limite = 650000;
int contatore = 0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condizione = PTHREAD_COND_INITIALIZER;
void *somma (){
printf("T somma: %d partito\\n",(int)pthread_self());
int sum = 0;
for(int i = 0; i < 1000; i++){
int generat... | 1 |
#include <pthread.h>
int somme_alea;
int cpt;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex_cpt = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond_cpt = PTHREAD_COND_INITIALIZER;
void* thread_rand(void * arg){
int random_val = (int) ((float) 10 * rand()... | 0 |
#include <pthread.h>
void * additionneur(void *);
pthread_t tid[2];
int nombre = 0;
pthread_mutex_t lock;
main( int argc, char *argv[] )
{
int i;
for (i=0; i<2; i++) {
pthread_create(&tid[i], 0, additionneur, 0);
}
for ( i = 0; i < 2; i++)
pthread_join(tid[i], 0);
printf(... | 1 |
#include <pthread.h>
double _glfwPlatformGetTime( void )
{
struct timeval tv;
gettimeofday( &tv, 0 );
return tv.tv_sec + (double) tv.tv_usec / 1000000.0 - _glfwLibrary.Timer.t0;
}
void _glfwPlatformSetTime( double time )
{
struct timeval tv;
gettimeofday( &tv, 0 );
_... | 0 |
#include <pthread.h>
int work_id = 0;
struct Job {
int id;
pthread_t tid;
pthread_cond_t cond;
pthread_mutex_t mutex;
int time;
char c;
struct Job* next;
};
void do_job(struct Job* jp) {
printf("%c", jp->c);
jp->time--;
work_id++;
if (work_id == 4)
work_id = 0;
pth... | 1 |
#include <pthread.h>
void* passenger_arrive(void* arg){
pthread_mutex_lock(&station.station_key);
station.waiting_passenger_count+=1;
printf("\\npassenger arrived, \\twaiting list = %d", station.waiting_passenger_count);
while(1){
if((station.available_seat_count<=0)||(station.tra... | 0 |
#include <pthread.h>
void vegas_thread_args_init(struct vegas_thread_args *a, int instance_id) {
a->instance_id = instance_id;
a->priority=0;
a->finished=0;
pthread_cond_init(&a->finished_c,0);
pthread_mutex_init(&a->finished_m,0);
}
void vegas_thread_args_destroy(struct vegas... | 1 |
#include <pthread.h>
int printflag = 1;
pthread_mutex_t gmutex = PTHREAD_MUTEX_INITIALIZER;
void s_handler(int signum)
{
pthread_mutex_lock(&gmutex);
printf("Enter signal handler function for : %d\\n", signum);
if (printflag)
printflag = 0;
else
... | 0 |
#include <pthread.h>
int nlibre = 123;
void* ALL_IS_OK = (void*)123456789L;
pthread_cond_t c;
pthread_mutex_t mutex;
void* allouer(void* n){
int i;
int* p_n = (int*)n;
for(i=0; i<100; i++){
pthread_mutex_lock(&mutex);
while(*p_n > nlibre){
pthread_cond_wait(&c, &mutex);
pthread_con... | 1 |
#include <pthread.h>
const char *test_doc = "Check that shared FS is migrated properly";
const char *test_author = "Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>";
enum kcmp_type {
KCMP_FILE,
KCMP_VM,
KCMP_FILES,
KCMP_FS,
KCMP_SIGHAND,
KCMP_IO,
KCMP_SYSVSEM,
KCMP_TYPES,
};
static ... | 0 |
#include <pthread.h>
static unsigned long rnd = 11;
int buffer[10];
int out = 0;
int in = 0;
int count = 0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t count_threshold;
void *producer(void *param);
void *consumer(void *param);
int genrnd(unsigned int n);
void printbuf();
i... | 1 |
#include <pthread.h>
int buf[10];
pthread_mutex_t m;
sem_t pro,cust;
int count;
int index1,index2;
void* pro1(void* p)
{
while(1)
{
sleep(rand()%5);
sem_wait(&pro);
pthread_mutex_lock(&m);
buf[index1]=count;
index1=(index1+1)%10;
printf("pro:... | 0 |
#include <pthread.h>
void* original(void* filename){
FILE* aux;
printf("\\nEl fichero que quiero leer. <%s>\\n", (char*)filename);
if((aux = fopen((char*)filename, "r")) == 0){
printf("\\nFichero no encontrado.");
exit(1);
}
do{
pthread_mutex_lock(&escritor);
... | 1 |
#include <pthread.h>
int numCookies =0;
int tid;
} thread_param;
pthread_mutex_t mutex;
pthread_cond_t emptyCond;
pthread_cond_t fullCond;
void* thread_consumer_func(void* pthread_arg)
{
thread_param* myParam = (thread_param*) pthread_arg;
int cookiesRetrieved =0;
while(cookiesRetrieved... | 0 |
#include <pthread.h>
struct thread_data {
long long soffset, foffset, offset;
pthread_t tid;
};
struct thread_data wthread[(1024)];
int nthreads;
unsigned int bwritten = 0;
pthread_mutex_t bwritten_mutex = PTHREAD_MUTEX_INITIALIZER;
long long fake_read(char *buffer, size_t size) ;
long long... | 1 |
#include <pthread.h>
pthread_t patron[90], theaterMan;
pthread_mutex_t Entrance, Exit;
sem_t Seats;
void wander () { sleep (2 + (rand() % 4)); }
void *patronJob (void *id) {
long myNo = (long)id;
int gotSeat;
while (1) {
do {
wander ();
} while (0 != pthread_mutex_trylock (&... | 0 |
#include <pthread.h>
int available_resources = 5;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
void *partC(void*);
void increase_count(int);
void decrease_count(int);
int main(int argc, char *argv[]){
if (argc != 2){
printf("incorrect nu... | 1 |
#include <pthread.h>
pthread_cond_t cond_tick;
pthread_mutex_t mutex_tick;
int capture_state = 2;
extern struct branch branches[BRANCH_NUM];
timer_t timerid;
int sync()
{
int retval = 0;
struct itimerspec its;
int i;
int expected_fn;
int current_fn;
unsigned long exp... | 0 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mymutex2 ;
pthread_cond_t mycond2 ;
pthread_mutex_t mymutex3 ;
pthread_cond_t mycond3 ;
void *thread1(void *);
void *thread2(void *);
int i=1;
void maketimeou... | 1 |
#include <pthread.h>
pthread_mutexattr_t mutex_attr;
pthread_mutex_t mutex;
struct to_info{
void (*to_fn)(void *);
void *to_arg;
struct timespec to_wait;
};
static void object_fun(void *arg)
{
printf("%d\\n", 21);
pthread_mutex_lock(&mutex);
printf("%d\\n", 23);
pthre... | 0 |
#include <pthread.h>
int BUFF_SIZE = 512;
int QUEUE_SIZE = 32;
char *queue;
char *next_pop;
char *next_push;
pthread_mutex_t lock;
int inc_pop()
{
pthread_mutex_lock(&lock);
if (next_pop >= queue + (BUFF_SIZE * QUEUE_SIZE)) {
next_pop = queue;
} else {
next_pop += BUF... | 1 |
#include <pthread.h>
void *produce(void* arg) {
for (;;) {
pthread_mutex_lock(&shared.mutex);
if (shared.nputs >= nitems) {
pthread_mutex_unlock(&shared.mutex);
return 0;
}
shared.buff[shared.nputs] = shared.nval;
shared.nputs++;
shared.nval++;
pthread_mutex_unlock(&sh... | 0 |
#include <pthread.h>
int A[10*3], B[10*3], LOG[3];
int RIS;
pthread_mutex_t lock;
void * single_thread(void * t)
{
int tid = (int) t;
int start = tid * 10;
int somma = 0;
for(int i = start; i < start + 10; i++)
somma += A[i] * B[i];
pthread_mutex_lock(&lock);... | 1 |
#include <pthread.h>
pthread_mutex_t mutex;
int cnt;
void espera_activa( int tiempo) {
time_t t;
t = time(0) + tiempo;
while(time(0) < t);
}
void *tareaA( void * args) {
printf("tareaA::voy a dormir\\n");
sleep(3);
printf("tareaA::me despierto y pillo mutex\\n");
pthread_mutex_lo... | 0 |
#include <pthread.h>
int quitflag;sigset_t mask;
pthread_mutex_t lock=PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t wait1=PTHREAD_COND_INITIALIZER;
void* thr_fn(void*arg)
{
int err,signo;
while(1)
{
if((err=sigwait(&mask,&signo))!=0) err_quit("sigwait failed\\n");
switch(signo)
{
case SIG... | 1 |
#include <pthread.h>
void *Producer(void *);
void *Consumer(void *);
pthread_cond_t condp;
pthread_cond_t condc;
pthread_mutex_t mutex;
int g_data[10];
int g_idx;
int main(void) {
pthread_t pid, cid;
pthread_cond_init(&condp, 0);
pthread_cond_init(&condc, 0);
pthread_mutex_init(&mutex... | 0 |
#include <pthread.h>
buffer_item buffer[6];
int index_counter = 0;
void *thread_Insert(void *arg);
void *thread_Remove(void *arg);
sem_t bin_sem;
pthread_mutex_t mutx;
char thread1[]="Thread A";
char thread2[]="Thread B";
char thread3[]="Thread C";
int main(int argc, char **argv)
{
... | 1 |
#include <pthread.h>
static void * SafeQueue_head(struct SafeQueue * self) {
pthread_mutex_lock(& self->mutex);
void * head = self->queue->head(self->queue);
pthread_mutex_unlock(& self->mutex);
return head;
}
static bool SafeQueue_pop(struct SafeQueue * self, void ** head) {
... | 0 |
#include <pthread.h>
int count = 0;
int thread_ids[3] = {0,1,2};
pthread_mutex_t count_mutex;
pthread_cond_t count_threshold_cv;
void *inc_count(void *idp)
{
int j,i;
double result=0.0;
int *my_id = idp;
for (i=0; i<10; i++) {
pthread_mutex_lock(&count_mutex);
count++;
... | 1 |
#include <pthread.h>
int gift_count = 26000;
pthread_mutex_t gift_count_lock = PTHREAD_MUTEX_INITIALIZER;
void* bring_gifts(void* box)
{
int i = 0;
int limit = 1000;
for (; i < limit; i++) {
pthread_mutex_lock(&gift_count_lock);
gift_count -= 1;
pthread_mutex_unlock(&gift_count_lock)... | 0 |
#include <pthread.h>
enum reorder { SORT, SHUFFLE };
struct int_list_s *next_node;
int val;
} int_list;
int_list *first_node;
} int_list_head;
int_list_head *head;
pthread_mutex_t *mutex;
int val;
unsigned int sleep_time;
} pthread_push_context;
void *_pthread_push(void *arg)
{
pthrea... | 1 |
#include <pthread.h>
void
ports_resume_bucket_rpcs (struct port_bucket *bucket)
{
pthread_mutex_lock (&_ports_lock);
assert_backtrace (bucket->flags & PORT_BUCKET_INHIBITED);
bucket->flags &= ~PORT_BUCKET_INHIBITED;
if (bucket->flags & PORT_BUCKET_BLOCKED)
{
bucket->flags &= ~POR... | 0 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
void *thread1(void *);
void *thread2(void *);
int i=1;
int main(void)
{
pthread_t t_a;
pthread_t t_b;
pthread_create(&t_a,0,thread1,(void *)0);
pthread_create(... | 1 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
long long sum = 0;
void * counting_thread(void *arg)
{
int offset = *(int *) arg;
pthread_mutex_lock(&mutex);
for (int i = 0; i < 100000000; i++)
{
sum += offset;
}
pthread_mutex_unlock(... | 0 |
#include <pthread.h>
struct arg_struct{
int lower;
int upper;
};
int NUMOFTHREADS;
double sum;
void *runner(void *param);
int arg;
pthread_mutex_t mutexSum;
int main(int argc, char *argv[])
{
pthread_attr_t attr;
sum = 0.0;
arg = atoi(argv[1]);
int NUMOFTHREADS = 4;
struct arg_struct arg... | 1 |
#include <pthread.h>
pthread_mutex_t * mutex_measurements;
pthread_mutex_t * mutex_alerts;
pthread_mutex_t mutex_file = PTHREAD_MUTEX_INITIALIZER;
pthread_t UCR;
pthread_t * list_of_UADS;
int * measurements;
int * alerts;
FILE * f;
void * start_reading(void * attr);
void * start_monitoring();... | 0 |
#include <pthread.h>
void *log_thread_function(void *arg);
int type;
int len;
}log_item;
int fd;
int total;
int curr;
char* buf;
pthread_mutex_t buf_lock;
pthread_cond_t log_cond;
}log_queue;
log_queue log_que = {-1, 0, 0, 0, PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER};
in... | 1 |
#include <pthread.h>
pthread_mutex_t mx, my;
int x=2, y=2;
void *thread1() {
int a;
pthread_mutex_lock(&mx);
a = x;
pthread_mutex_lock(&my);
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y +... | 0 |
#include <pthread.h>
static int bloom_table[1000000] = {0};
pthread_mutex_t bt_lock = PTHREAD_MUTEX_INITIALIZER;
static unsigned int encrypt(char *key, unsigned int id)
{
unsigned int val = 0;
switch(id){
case 0:
val = times33(key); break;
case 1:
... | 1 |
#include <pthread.h>
void *functionC();
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int counter = 0;
void *functionC()
{
pthread_mutex_lock( &mutex1 );
counter++;
printf("Counter value: %d\\n",counter);
pthread_mutex_unlock( &mutex1 );
}
main()
{
int rc1, rc2;
pthread_t... | 0 |
#include <pthread.h>
pthread_mutex_t mutex0 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
int NR_JOBS =0;
int jobID = 0;
struct job {
int job_id;
int nr_phases;
int jobTime;
int current_phase;
int p... | 1 |
#include <pthread.h>
pthread_mutex_t mutex_a;
pthread_mutex_t mutex_b;
void*
thread_a(void* arg)
{
printf("Hello from Thread A.\\n");
pthread_mutex_lock(&mutex_a);
sleep(1);
pthread_mutex_lock(&mutex_b);
printf("Doing important work in Thread A.\\n");
pthread_mutex_unlo... | 0 |
#include <pthread.h>extern int __VERIFIER_nondet_int(void);
extern void __VERIFIER_error() ;
int element[(800)];
int head;
int tail;
int amount;
} QType;
pthread_mutex_t m;
int __VERIFIER_nondet_int();
int stored_elements[(800)];
_Bool enqueue_flag, dequeue_flag;
QType queu... | 1 |
#include <pthread.h>
int consumers;
size_t buffer_size;
char* buffer;
pthread_cond_t* read_lock;
pthread_mutex_t* write_lock;
bool eof;
} buffer_t;
int id;
FILE* fd;
buffer_t* buffer;
} thread_spec;
void* writer (void* arg) {
thread_spec* specs = (thread_spec*) arg;
int... | 0 |
#include <pthread.h>
double nanotime()
{
struct timespec now;
if (clock_gettime(CLOCK_MONOTONIC, &now)) {
do { fprintf(stderr, "Can't read clock.\\n"); perror(""); exit(1); } while (0);
}
return (double)now.tv_sec + 1e-9 * (double)now.tv_nsec;
}
struct incrementer_input
{
int32_t... | 1 |
#include <pthread.h>
pthread_mutex_t the_mutex;
pthread_cond_t condC;
pthread_cond_t condP;
int bufferSize = 10;
int buffer = 0;
int total = 0;
void *producer1(void *ptr)
{
printf("pro1\\n");
for(int i = 0; i < 50; i++)
{
pthread_mutex_lock(&the_mutex);
if(total == 50){
exit(0);
}
w... | 0 |
#include <pthread.h>
double *a_t;
double *b_t;
double sum;
pthread_mutex_t mutex;
double two_norm(double *a, double *b, long length){
double ret_val = 0.0;
for(long i = 0; i < length; ++i){
ret_val += a[i] * b[i];
}
return ret_val;
}
void *two_norm_thread(void *arg)
{
long id = (lo... | 1 |
#include <pthread.h>
pthread_mutex_t cs0, cs1;
int globalX = 0;
int globalY = 0;
void
print_safe()
{
printf("-------- safe\\n");
}
void
print_deadlock()
{
printf("------------- could deadlock\\n");
}
void * work0 (void *arg)
{
pthread_mutex_lock (&cs0);
printf("work0: got lock 0\\n");
... | 0 |
#include <pthread.h>
sem_t chopsticks[5];
pthread_mutex_t mutex;
void *philosopher(void *arg){
int id = (int) arg;
int state = 1;
int right = (id + 1) % 5;
int left = (id + 5 - 1) % 5;
char ptrState[32];
while(1){
switch(state){
case 1:
usleep(... | 1 |
#include <pthread.h>
pthread_mutex_t mutex1=PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2=PTHREAD_MUTEX_INITIALIZER;
void *thread_worker(void *);
void critical_section(int thread_num,int i);
int main(void){
int rtn,i;
pthread_t pthread_id;
rtn=pthread_create(&pthread_id,0,(void *)thread_wo... | 0 |
#include <pthread.h>
struct foo {
int id;
int refs;
pthread_mutex_t mutex;
};
struct foo* alloc(int id) {
struct foo* p;
if ((p = (struct foo*)malloc(sizeof(struct foo))) != 0) {
p->id = id;
p->refs = 1;
if (pthread_mutex_init(&p->mutex, 0) != 0) {
free(p);
return ... | 1 |
#include <pthread.h>
{
char request_type;
int account;
int target;
int amount;
} request;
pthread_mutex_t lock;
int shared_balance = 0;
void *withdraw_money_thread(int amount)
{
pthread_mutex_lock(&lock);
printf("\\n Processing withdraw request.. current balance %d", shared_balance);
... | 0 |
#include <pthread.h>
int fork[2];
pthread_mutex_t lock[2];
int meals[2];
int take_up(int pid, int fid)
{
pthread_mutex_lock(lock + fid);
int success = 0;
if (fork[fid] == 1) {
fork[fid] = 0;
success = 1;
}
pthread_mutex_unlock(lock + fid);
return success;
}
... | 1 |
#include <pthread.h>
int balanco=10000;
pthread_t threads[2];
pthread_mutex_t mutex_balanco;
void *deposita(void *valor)
{
int i,*a= (int *) valor;
pthread_mutex_lock(&mutex_balanco);
balanco += *a;
pthread_mutex_unlock(&mutex_balanco);
pthread_exit(0);
}
void *saque(void ... | 0 |
#include <pthread.h>
const int MAX_PRODUCER = 20;
const int MAX_CONSUMER = 20;
int head = 0;
int tail = 0;
int buffer[5];
pthread_mutex_t mutex;
sem_t emptyBuffers;
sem_t fullBuffer;
void initialize_locks()
{
pthread_mutex_init(&mutex,0);
sem_init(&emptyBuffers,0,5);
sem_init(&... | 1 |
#include <pthread.h>
pthread_mutex_t proc[2];
pthread_t id[2];
pthread_cond_t condn[2];
int clock_t_1, clock_t_2=0, clock_t_3=0;
void * increment_1(void * arg)
{
int * interval;
interval=(int *)arg;
while(1)
{
sleep(1);
clock_t_1 = clock_t_1 + (*interval);
printf("\\nclock 1 = %d", clo... | 0 |
#include <pthread.h>
void *worker(void *param);
pthread_mutex_t mutex;
int circle_count = 0;
double random_double()
{
return random() / ((double)32767 + 1);
}
int main (int argc, const char * argv[]) {
int darts_per_thread = 50000000/ 2;
int i;
double estimated_pi;
pthread_t tids[2... | 1 |
#include <pthread.h>
int thread_count;
pthread_mutex_t thread_count_mutex;
pthread_cond_t thread_count_condvar;
void
incr_thread_count (void)
{
pthread_mutex_lock (&thread_count_mutex);
++thread_count;
if (thread_count == 4)
pthread_cond_signal (&thread_count_condvar);
pthread_m... | 0 |
#include <pthread.h>
{
char estado;
pthread_t thread;
} filosofo_t;
filosofo_t * filosofos;
{
char estado;
sem_t semaphore;
} garfo_t;
garfo_t * garfos;
int numFG = 0;
pthread_mutex_t mutexImpressao;
pthread_cond_t filosofosInicializados;
pthread_mutex_t mutexFilosofosInicializ... | 1 |
#include <pthread.h>
pthread_mutex_t mutexl = PTHREAD_MUTEX_INITIALIZER;
int global_data = 0;
void read_data();
void set_data();
int main(void)
{
pthread_t thread1, thread2;
int thread_return1, thread_return2;
int i;
for (i = 0; i < 5; i++)
{
thread_return1 = pthrea... | 0 |
#include <pthread.h>extern void __VERIFIER_error() ;
int element[(800)];
int head;
int tail;
int amount;
} QType;
pthread_mutex_t m;
int __VERIFIER_nondet_int();
int stored_elements[(800)];
_Bool enqueue_flag, dequeue_flag;
QType queue;
int init(QType *q)
{
q->head=0;
q->tail... | 1 |
#include <pthread.h>
int **A; int **W; int size; int number_threads;
pthread_mutex_t **mutex;
pthread_cond_t Condition;
pthread_cond_t **CondMatrix;
int DEBUG = 0;
int main(int argc, char * argv[]){
Lab2_loadinput(&A, &size);
number_threads = parse_number_threads(argc, argv, size);
create_m... | 0 |
#include <pthread.h>
void tcp_setaddress(struct tcp_socket* inputsocket, char* inputstring) {
inputsocket->servaddr.sin_addr.s_addr = inet_addr(inputstring);
}
void tcp_setport(struct tcp_socket* inputsocket, int port) {
inputsocket->servaddr.sin_port = htons(port);
}
void tcp_createsocket(str... | 1 |
#include <pthread.h>
pthread_mutex_t foodLock, forkLock;
pthread_cond_t forkCond;
pthread_mutex_t forks[10];
pthread_t philosophers[10];
int id;
} param;
void get_forks(int phil, int fork1, int fork2){
pthread_mutex_lock(&forkLock);
printf("locking forks %d\\n", phil);
int res1, res2;
i... | 0 |
#include <pthread.h>
pthread_mutex_t mx, my;
int x=2, y=2;
void *thread1() {
int a;
pthread_mutex_lock(&mx);
a = x;
pthread_mutex_lock(&my);
y = y + a;
y = y + a;
y = y + a;
y = y + a;
y = y + a;
pthread_mutex_unlock(&my);
a = a + 1;
pthread_mutex_lock(&my);
y = y + a;
y = y + a;
y... | 1 |
#include <pthread.h>
pthread_mutex_t mutex_count;
pthread_cond_t cond_produce;
pthread_cond_t cond_consume;
int count = 0;
void *produce(void *arg)
{
srand((int)time(0));
while (1)
{
pthread_mutex_lock(&mutex_count);
while (5 == count)
{
pthread_cond_wait(&cond_produce, &mutex_co... | 0 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_mutex_t s[5];
state_t state[5];
int done;
int eatcount[5];
void philosopher(void *);
void think(int i);
void take_forks(int i);
void eat(int i);
void put_forks(int i);
void test(int i);
void mysleep(int milliseconds);
int main(int argc... | 1 |
#include <pthread.h>
pthread_mutex_t monitor;
pthread_cond_t red[3];
int santaClaus=0;
int reindeer=1;
int consultations=2;
int reindeerNum=0;
int elvesNum=0;
void *Elf(){
printf("Elf is waiting at the door\\n");
pthread_mutex_lock(&monitor);
elvesNum++;
if (elvesNum==3){
pthr... | 0 |
#include <pthread.h>
struct log_head head_table[HASH_SIZE];
void debug(char *p, int len)
{
while(len--)
printf("%c",*p++);
printf("\\n");
}
void hash_init()
{
int i;
for(i=0; i<HASH_SIZE; ++i)
{
pthread_mutex_init(&head_table[i].head_lock, 0);
head_table[i].head = 0;
}
}
static void _... | 1 |
#include <pthread.h>
struct arg_set {
char *fname;
int count;
struct arg_set **mailboxp;
pthread_mutex_t *lockp;
pthread_cond_t *flagp;
};
static void *count_words(void *a);
static int do_count(char *filename);
static void mnarrate(char *str);
static void cnarrate(char *str);
int main(... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.