text stringlengths 192 6.24k | label int64 0 1 |
|---|---|
#include <pthread.h>
int counter, busy;
pthread_mutex_t mutex;
pthread_cond_t cv;
} control_t;
control_t control = {0, 1, PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER};
void cleanup_handler(void *args)
{
control_t *s = (control_t *)args;
s->counter--;
pri... | 1 |
#include <pthread.h>
int var = 1, num = 5;
pthread_mutex_t m_var, m_num;
void *tfn(void *arg)
{
int i = (int)arg;
if (i == 1) {
printf("*\\n");
pthread_mutex_lock(&m_var);
var = 22;
sleep(1);
pthread_mutex_lock(&m_num);
num = 66;
... | 0 |
#include <pthread.h>
unsigned long long calls = 0, ticks = 0;
double sum = 0;
pthread_mutex_t calls_lock = PTHREAD_MUTEX_INITIALIZER;
static void timer_tick(union sigval _arg)
{
(void)_arg;
unsigned long long res;
pthread_mutex_lock(&calls_lock);
res = calls;
calls = 0;
pthread_mutex_u... | 1 |
#include <pthread.h>
struct account {
double balance;
pthread_mutex_t mutex;
};
account *myacct;
void *threadMain(void *);
pthread_t *tids;
int numThreads;
int count;
int main(int argc, char **argv)
{
int i;
if (argc < 2) {
fprintf(stderr, "Usage: %s <numThreads> <iterations>\\n", argv[0... | 0 |
#include <pthread.h>
int quitflag;
sigset_t mask;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t waitloc = PTHREAD_COND_INITIALIZER;
void *
thr_fn(void *arg)
{
int err, signo;
for (;;)
{
err = sigwait(&mask, &signo);
if (err != 0)
err_exit(err, "sigwait failed");
sw... | 1 |
#include <pthread.h>
static void *threadMain(void *dummy);
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int numWaiting = 0;
int
main()
{
int x[10], i;
pthread_t t[10];
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_s... | 0 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_cond_t condv;
int64_t size;
struct nu_free_cell* next;
} nu_free_cell;
static const int64_t CHUNK_SIZE = 65536;
static const int64_t CELL_SIZE = (int64_t)sizeof(nu_free_cell);
static nu_free_cell* nu_free_list = 0;
static int64_t nu_mall... | 1 |
#include <pthread.h>
volatile int enqueued = 0;
volatile int dequeued = 0;
pthread_mutex_t queue_mutex;
pthread_cond_t queue_emptiness_cv;
void *consumer( void *arg )
{
intptr_t id = ( intptr_t ) arg;
while ( 1 ) {
pthread_mutex_lock( &queue_mutex );
while ( dequeue... | 0 |
#include <pthread.h>
unsigned int counts[3] = {0,0,0};
pthread_mutex_t m;
char* fileName;
} child_t;
char* fileName;
int charType;
} grandchild_t;
void* child_thread_function(void*);
void* grandchild_thread_function(void*);
bool existsFile(char*);
int main(int argc, char* argv[... | 1 |
#include <pthread.h>
pthread_mutex_t lock;
pthread_barrier_t barrier;
static int shared = 0;
static inline void acquire_lock()
{
pthread_mutex_lock(&lock);
}
static inline void release_lock()
{
pthread_mutex_unlock(&lock);
}
void *thread_func(void *arg)
{
int i;
pthread_barri... | 0 |
#include <pthread.h>
static char *amconfigs[MAX_CONFIG] = {0};
static int amconfig_inited = 0;
static pthread_mutex_t config_lock;
static char *malloc_config_item()
{
return malloc(CONFIG_PATH_MAX + CONFIG_VALUE_MAX + 8);
}
static void free_config_item(char *item)
{
free(item);
}
stat... | 1 |
#include <pthread.h>
void *searchfile(void *);
char *pattern;
pthread_t fileThreadsCall[50];
pthread_mutex_t mutexfile=PTHREAD_MUTEX_INITIALIZER;
void *searchfile(void *filename){
FILE *fileptr;
char *tmpfilename=filename;
char line[1000];
if ( (fileptr=fopen(tmpfilename,"r")) == ... | 0 |
#include <pthread.h>
int NumProcs;
pthread_mutex_t SyncLock;
pthread_cond_t SyncCV;
int SyncCount;
pthread_mutex_t ThreadLock;
int Count;
int num_threads=0;
int **grid;
int xdim;
int ydim;
int timesteps;
void Barrier()
{
int ret;
pthread_mutex_lock(&SyncLock);
SyncCount++;
if(SyncCou... | 1 |
#include <pthread.h>
struct paramA{
int sock;
int nb_processus;
char ** processus;
};
struct paramB{
int sock;
char * com;
};
struct paramC{
char * mes;
};
struct paramD{
int sock;
};
pthread_mutex_t verrou;
int initSocketClient(char *host, short port){
int sock, val;
stru... | 0 |
#include <pthread.h>
void usage(void)
{
printf("getopt [-d?] [-c count]\\n");
errno = 0;
}
int
main(int argc, char **argv)
{
struct timeval starttime, endtime;
pthread_mutex_t lock;
int count = 1000000;
int debug = 0;
int i;
char word[256];
extern int optind, opterr;
ext... | 1 |
#include <pthread.h>
unsigned long val = 0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *fun1(void *args)
{
unsigned long i = 0;
printf("thread id: %lu args: %s\\n", pthread_self(), (char*)args);
pthread_mutex_lock(&mutex);
for (i = 0; i < 1000000; i++)
... | 0 |
#include <pthread.h>
struct prodcons
{
int buffer[16];
pthread_mutex_t lock;
int readpos, writepos;
pthread_cond_t notempty;
pthread_cond_t notfull;
};
void init(struct prodcons *b)
{
pthread_mutex_init(&b->lock, 0);
pthread_cond_init(&b->notempty, 0);
pthread_cond_init(&b->notf... | 1 |
#include <pthread.h>
void *threadfunc(void *);
void unlock(void *);
pthread_mutex_t mutex;
pthread_cond_t cond;
int share;
int
main(int argc, char *argv[])
{
pthread_t thread;
int ret;
printf("Test of CV state after cancelling a wait\\n");
ret = pthread_mutex_init(&mutex, 0);
if (ret) e... | 0 |
#include <pthread.h>
void* funProd(void *arg);
void* funPosr(void *arg);
void* funKons(void *arg);
struct bufCykl
{
int dane[16];
int we;
int wy;
int licznik;
pthread_mutex_t *semafor;
pthread_cond_t *cond;
};
int odczyt(struct bufCykl *buf);
void zapis(struct bufCykl *buf, int war... | 1 |
#include <pthread.h>
int num_threads = 30;
int N = 100000;
float result;
pthread_mutex_t mutex;
struct ThreadInput {
float dx;
int id;
float result;
};
float f(float x) {
return sin(x);
}
void * thread_func1(void * arg_ptr);
void * thread_func2(void * arg_ptr);
main() {
... | 0 |
#include <pthread.h>
int THREADNUM = 1;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_t* threads;
void*
printHello(void* args)
{
int i = 0;
pthread_mutex_lock(&mutex);
for(;i < 1000000; i++){
fprintf(stdout,"Hello ");
fprintf(stdout,"World!\\n");
}
... | 1 |
#include <pthread.h>
unsigned int TEST_VALUE_CA[8][3] = {
{CMD_WRITE, REG_INTERRUPT_MASK_0, 0x555555},
{CMD_SUB, 2, 0},
{CMD_WRITE, REG_INTERRUPT_MASK_1, 0xFF7777},
{CMD_SUB, 0, 0},
{CMD_WRITE, REG_USB, 0x001001},
{CMD_UNSUB, 0, 0},
{CMD_UNSUB, 2, 0}
};
int VT_mc13783_CA_setup(... | 0 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int comida = 6;
struct filosofo{
char * nombre;
int cantComida;
pthread_mutex_t ten1;
pthread_mutex_t ten2;
};
struct tenedor{
int estado;
};
void * comer( void * h1)
{
struct filosofo * fil;
... | 1 |
#include <pthread.h>
int num_thr;
pthread_mutex_t mutex;
struct thread_data{
double *A;
int left;
int right;
};
double get_wall_time(){
struct timeval time;
if (gettimeofday(&time,0)){
return 0;
}
return (double)time.tv_sec + (double)time.tv_usec * .000001;
}
int ... | 0 |
#include <pthread.h>
int buffer[4];
int in;
int out;
int buffer_is_empty()
{
return in == out;
}
int buffer_is_full()
{
return (in + 1) % 4 == out;
}
int get_item()
{
int item;
item = buffer[out];
out = (out + 1) % 4;
return item;
}
void put_item(int item)
{
buffe... | 1 |
#include <pthread.h>
void *(*process)(void *arg);
void *arg;
struct task_worker *next;
}t_task;
pthread_mutex_t lock;
pthread_cond_t cond_lock;
t_task *queue_task;
int shutdown;
pthread_t *threadid;
int max_thread_num;
int cur_queue_size;
}t_task_pool;
... | 0 |
#include <pthread.h>
int q[5];
int qsiz;
pthread_mutex_t mq;
void queue_init ()
{
pthread_mutex_init (&mq, 0);
qsiz = 0;
}
void queue_insert (int x)
{
int done = 0;
printf ("prod: trying\\n");
while (done == 0)
{
pthread_mutex_lock (&mq);
if (qsiz < 5)
... | 1 |
#include <pthread.h>
int buf[10];
pthread_mutex_t block;
sem_t filled;
sem_t empty;
int pos=0;
void* producerFunc(void *args)
{
int item;
while(1)
{
item=30;
sem_wait(&empty);
pthread_mutex_lock(&block);
if(pos<10)
{
buf[pos]=item;
pos++;
}
pthread_mutex_unlock(&block);
... | 0 |
#include <pthread.h>
static pthread_mutex_t logLock;
int bstapp_logging_init(void)
{
int rv = 0;
FILE *fp;
rv = pthread_mutex_init(&logLock, 0);
_BSTAPP_ASSERT_NET_ERROR( (rv == 0), "BSTAPP : Error creating logging mutex \\n");
fp = fopen(BSTAPP_COMMUNICATION_LOG_FILE, "w... | 1 |
#include <pthread.h>
enum {
STATE_THINKING,
STATE_HUNGRY,
STATE_EATING
};
struct strFil {
int id;
int state;
int numRefeicoes;
sem_t semAlterandoGrafos;
sem_t semAguardandoGarfo;
};
int numFilosofos;
Filosofo * filosofos;
pthread_mutex_t lockImprimindoEstad... | 0 |
#include <pthread.h>
int quitflag;
sigset_t mask;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t waitloc = PTHREAD_COND_INITIALIZER;
void *thr_fn(void *arg)
{
int err, signo;
for (;;)
{
err = sigwait(&mask, &signo);
if (err != 0)
err_exit(err, "sigwait fail... | 1 |
#include <pthread.h>
pthread_mutex_t mutex;
int cant;
int buffer[5];
int DATOS_A_PRODUCIR = 20;
void Productor()
{
int dato, i, pos;
pos = 0;
dato = 1000;
i = 0;
while (i < DATOS_A_PRODUCIR) {
sleep(1);
pthread_mutex_lock(&mutex);
while (cant... | 0 |
#include <pthread.h>
pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER;
int isGreen1 (int s) {
return s == 0;
}
int isGreen2 (int s) {
return s == 0;
}
void * signal1(void* d) {
int status = 0;
b1:
printf("1 -> GREEN\\n");
s... | 1 |
#include <pthread.h>
pthread_t tid[8];
pthread_mutex_t mutex;
int *array;
int length = 1000000000;
int private_count[8];
int count = 0;
int double_count = 0;
int t = 8;
int max_threads = 0;
void *count3s_thread(void *arg) {
int i;
struct timeval tv1,tv2;
int length_per_thread = length/max_... | 0 |
#include <pthread.h>
int g_flag = 0;
pthread_t t1, t2;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
void *t1_func(void *param)
{
printf("this is thread 1\\n");
pthread_mutex_lock(&mutex);
g_flag = 1;
pthread_cond_signal(&cond)... | 1 |
#include <pthread.h>
int val;
struct node *next;
pthread_mutex_t mutex;
} node;
node sentinel = {32767, 0, PTHREAD_MUTEX_INITIALIZER};
node dummy = {INT_MIN, &sentinel, PTHREAD_MUTEX_INITIALIZER};
node *list = &dummy;
bool contains(int item) {
node *current = list->next;
while (curren... | 0 |
#include <pthread.h>
struct xurfaced xurfaced;
static void *xurfaced_thread_render(void *arg)
{
struct xurfaced *xurfaced = (struct xurfaced *)arg;
struct timespec ts;
struct timeval tv;
while (xurfaced->running)
{
pthread_mutex_lock(&xurfaced->mutexMenu);
x... | 1 |
#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;
... | 0 |
#include <pthread.h>
int value;
int n_wait;
pthread_mutex_t lock;
pthread_cond_t cond;
}sem_t;
int sem_init(sem_t *sem, int pshared, unsigned int value);
int sem_wait(sem_t *sem);
int sem_post(sem_t *sem);
int sem_trywait(sem_t *sem);
int sem_getvalue(sem_t *sem, int *sval);
int sem_des... | 1 |
#include <pthread.h>
pthread_mutex_t ma, mb;
int data1, data2;
pthread_mutex_t ja, jb;
int join1, join2;
void * thread1(void * arg)
{
pthread_mutex_lock(&ma);
data1++;
pthread_mutex_unlock(&ma);
pthread_mutex_lock(&ma);
data2++;
pthread_mutex_unlock(&ma);
pthread_mutex_lock... | 0 |
#include <pthread.h>
int g_Count = 0;
int nNum, nLoop;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t my_condition=PTHREAD_COND_INITIALIZER;
void *consume(void* arg)
{
int inum = 0;
inum = (int)arg;
while(1)
{
pthread_mutex_lock(&mutex);
printf("consum:%d\\n", in... | 1 |
#include <pthread.h>
pthread_mutex_t lock;
pthread_cond_t thereAreOxygen, thereAreHydrogen;
int numberOxygen = 0 , numberHydrogen=0;
int activeOxygen = 0 , activeHydrogen=0;
long currentOxygen = 0 , currentHydrogen=0;
int flagExit=0;
void dataIn(){
int var=-3;
if(numberHydrogen==1 && fl... | 0 |
#include <pthread.h>
pthread_t io_thread;
char input[64000];
uint16_t input_size, input_offset;
uint8_t io_mode;
char vm_shared_io_buffer[64000];
uint16_t io_buffer_index, io_buffer_ri;
pthread_mutex_t io_mutex;
int valid_program_char(char ch) {
return ('a' <= ch && 'z' >= ch) || ... | 1 |
#include <pthread.h>
pthread_mutex_t m[1];
pthread_cond_t c[1];
volatile long x, y;
void produce(long batch_id, long n_consumers) {
pthread_mutex_lock(m);
assert(y == batch_id * n_consumers);
while (x != y) {
pthread_cond_wait(c, m);
}
y += n_consumers;
pthread_cond... | 0 |
#include <pthread.h>
int iCounter = 0;
pthread_mutex_t pmMux1 = PTHREAD_MUTEX_INITIALIZER;
void *PrintMessage (void *pvData)
{
char *pszMessage = (char *)pvData;
pthread_mutex_lock (&pmMux1);
iCounter += 1;
printf ("In %s: iCounter=%d\\n", pszMessage, iCounter);
usleep(200);
... | 1 |
#include <pthread.h>
static pthread_mutex_t lock;
static pthread_cond_t cond;
static int running;
static int go;
static char *port;
void *worker(void *arg)
{
struct mrpc_conn_set *cset=arg;
struct mrpc_connection *conn;
int i;
int ret;
pthread_mutex_lock(&lock);
running++;
pthread_con... | 0 |
#include <pthread.h>
static void sig_alrm(int signo);
static sigjmp_buf jmpbuf;
static void sig_alrm(int signo)
{
siglongjmp(jmpbuf, 1);
}
int udp_recv(int sockfd, struct packet_t* packet, struct sockaddr* sockAddr)
{
int len = sizeof(*sockAddr);
bzero(sockAddr, len);
if(recvfrom(sockfd, ... | 1 |
#include <pthread.h>
struct foo *fh[29];
pthread_mutex_t hashlock = PTHREAD_MUTEX_INITIALIZER;
struct foo
{
int f_count;
pthread_mutex_t f_lock;
int f_id;
struct foo *f_next;
};
struct foo *foo_alloc(int id)
{
struct foo *fp;
int idx;
if((fp = malloc(sizeof(stru... | 0 |
#include <pthread.h>
static int items_sent = 0;
static int items_recieved = 0;
char buf[10];
int items_onBuffer;
int in, out;
pthread_mutex_t mutex;
pthread_cond_t add;
pthread_cond_t take;
} buffer_t;
buffer_t buff;
void * producer(void *);
void * consumer(void *);
init_buffer(... | 1 |
#include <pthread.h>
pthread_mutex_t hMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t h2Mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t oMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t conditionHydrogen = PTHREAD_COND_INITIALIZER;
pthread_cond_t conditionH2ydrogen = PTHREAD_COND_INITIALIZE... | 0 |
#include <pthread.h>
struct producers
{
int buffer[4];
pthread_mutex_t lock;
int readpos, writepos;
pthread_cond_t notempty;
pthread_cond_t notfull;
};
void init(struct producers *b)
{
pthread_mutex_init(&b->lock,0);
pthread_cond_init(&b->notempty,0);
pthread_con... | 1 |
#include <pthread.h>
int cs_work(const char *pathname){
struct dirent *dirEntry;
DIR *dir;
dir = opendir(pathname);
dirEntry = readdir(dir);
int counter = 0;
while ((dirEntry = readdir(dir))){
char p[1<<10];
int strLength = snprintf(p, sizeof(p) - 1, "%s/%s"... | 0 |
#include <pthread.h>
int shared_count;
int thread_count;
pthread_mutex_t barrier_mutex;
void Usage(char* prog_name);
void *Thread_work(void* rank);
int main(int argc, char* argv[]) {
long thread;
pthread_t* thread_handles;
double start, finish;
if (argc != 2) Usage(argv[0]... | 1 |
#include <pthread.h>
const char * working_extension;
int working_count = 0;
int working_interval = 0;
int working_progress = 0;
pthread_mutex_t parameter_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t timelapse_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_t worker;
bool working = 0;
bool... | 0 |
#include <pthread.h>
void *takeThisRequest(char *buffer, int new_socket, int typeCon) {
char request[1024];
strcpy(request, buffer);
char *split;
char *word;
char *requestFile;
char *connectionType;
split = strtok(request, " ");
char connection[10];
int flag... | 1 |
#include <pthread.h>
void init_sem_and_mutexes();
void destroy_sem_and_mutexes();
int main()
{
int err=0;
init_sem_and_mutexes();
err = udp_init_client(&tinfo_connection.conn, UDP_PORT, SERVER_IP);
if (err!=0)
{
printf("error connecting to server");
}
printf("created udp conn\\n");
pt... | 0 |
#include <pthread.h>
{
int side;
pid_t monkey_id;
} pthread_args;
int crossing;
int goingRight;
int goingLeft;
int count;
pthread_mutex_t mux;
sem_t sem;
int side(void);
void* monkeyDay(void* monkey_args);
void crossRight(pthread_args* monkey);
void crossLeft(pthread_args* monkey);
void cr... | 1 |
#include <pthread.h>
pthread_mutex_t entry_mutex = PTHREAD_MUTEX_INITIALIZER;
void* thread_func(void *data) {
struct parking_details *pdata = (struct parking_details *)data;
pthread_mutex_lock(&entry_mutex);
printf("\\n enter the car details thread : %d",pdata->thread_instance... | 0 |
#include <pthread.h>
pthread_mutex_t chopsticks[5];
void chopsticks_init(){
int i = 0;
for (i = 0; i<5; i++){
pthread_mutex_init(&chopsticks[i], 0);
}
return;
}
void chopsticks_destroy(){
int i = 0;
for (i = 0; i<5; i++){
pthread_mutex_destroy(&chopsticks[i]);
}
return;
}
... | 1 |
#include <pthread.h>
int deb; int fin; int *res; int *tab;
pthread_mutex_t*mut;
} Tableau;
void *cherche(void *a) {
int i;
Tableau *t=(Tableau *)a;
for(i=t->deb;i<t->fin;i++){
pthread_mutex_lock(t->mut);
if(*(t->res)< t->tab[i])
*(t->res)=t->tab[i];
pthread_mutex_unlock(t->mut);... | 0 |
#include <pthread.h>
int count;
pthread_mutex_t mutex;
pthread_cond_t condition_var;
} Semaphore;
pthread_mutex_t mutexP = PTHREAD_MUTEX_INITIALIZER;
Semaphore siA = {0, PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER};
Semaphore siB = {0, PTHREAD_MUTEX_INITIALIZER, PTHR... | 1 |
#include <pthread.h>
pthread_mutex_t pro_mutex;
unsigned char process_num = 0;
void createpro(char *argname, unsigned short argpri, unsigned short arglen, struct process **arghead)
{
static unsigned char n = 0;
struct process *process_node;
void insert_pro(struct process *, struct process **);... | 0 |
#include <pthread.h>
struct minmax{
int value;
int xpos;
int ypos;
};
pthread_mutex_t maxLock;
pthread_mutex_t minLock;
pthread_mutex_t totalLock;
pthread_mutex_t rowCountLock;
int numWorkers;
int total;
int rowCount;
struct minmax min;
struct minmax max;
double read_timer() {
static b... | 1 |
#include <pthread.h>
pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
double pi_approx = 0;
double get_term(double n) {
double term = 4.0 / (2 * n + 1);
if ((int)floor(n) & 1) {
term = 0 - term;
}
return term;
}
double start;
double end;
}params;
params * params_new(double start,... | 0 |
#include <pthread.h>
void taSleepingTime(void)
{
int time = rand() % SLEEP_MAX + 1;
sleep(time);
}
void* teachingAssistant()
{
while(1)
{
sem_wait(&studentSemaphore);
pthread_mutex_lock(&mutex);
printf("Teaching Assistant helping student %d\\n",seat[studentSeated]);
seat[stu... | 1 |
#include <pthread.h>
int handleRouting(struct RoutingInfo senderRtngInfo)
{
int i,j;
if( myNodeNum == senderRtngInfo.originator )
{
free(senderRtngInfo.rt_sender);
return 0;
}
if( senderRtngInfo.counter <= NodeRtngMsgCounter[senderRtngInfo.originator] )
{
for(i=0; i < rt_num_entr... | 0 |
#include <pthread.h>
long timeval_diff(struct timeval *t2, struct timeval *t1)
{
long diff = (t2->tv_usec + 1000000 * t2->tv_sec) - (t1->tv_usec + 1000000 * t1->tv_sec);
return (diff);
}
void error(int err, char *msg)
{
fprintf(stderr,"%s a retourné %d, message d'erreur :... | 1 |
#include <pthread.h>
void *v3_helper(void *path){
char *file, *file_ext, new_path[1000];
DIR *inDir;
struct dirent *inDirent;
struct stat st;
pthread_t thread;
pthread_mutex_lock(&log_mutex);
num_threads++;
pthread_mutex_unlock(&log_mutex);
inDir = opendir(path);
i... | 0 |
#include <pthread.h>
struct foo *fh[29];
pthread_mutex_t hashlock = PTHREAD_MUTEX_INITIALIZER;
struct foo{
int f_count;
pthread_mutex_t f_lock;
int f_id;
struct foo *f_next;
};
struct foo *foo_alloc(int id)
{
struct foo *fp;
int idx;
if ((fp = malloc(sizeof (struct... | 1 |
#include <pthread.h>
int threads = 0;
pthread_mutex_t mutex;
pthread_cond_t cond_pode_ler;
pthread_cond_t cond_pode_escrever;
int lendo = 0;
int escrevendo = 0;
int querendo_escrever = 0;
unsigned long mix(unsigned long a, unsigned long b, unsigned long c);
void entra_leitura()
{
pthr... | 0 |
#include <pthread.h>
void draw_ball(int x, int y, int c)
{
circlefill(screen, x, y, L, c);
}
void print_id_task(int id, int x, int y, int color){
textprintf_ex(screen, font, x, y, color, BGC, "T%d", id);
}
void periodicBall_testParam() {
int i, j = 0;
int dcol = BGC;
int *pun_col;
int... | 1 |
#include <pthread.h>
pthread_mutex_t lock;
pthread_mutex_t lock2;
int value;
int value2;
sem_t sem;
void *functionWithCriticalSection(int* v2) {
pthread_mutex_lock(&(lock));
pthread_mutex_lock(&(lock2));
value = value2 + *v2;
value2 = value;
pthread_mutex_unlock(&(lock2));
... | 0 |
#include <pthread.h>
void
cond_wait (pthread_cond_t *cond, pthread_mutex_t *mut)
{
pthread_mutex_lock(mut);
pthread_cond_wait (cond, mut);
pthread_mutex_unlock (mut);
}
void
noreturn (void)
{
pthread_mutex_t mut;
pthread_cond_t cond;
pthread_mutex_init (&mut, 0);
pthread_cond_init ... | 1 |
#include <pthread.h>
void *find_bmp(void *path){
char *file, *file_ext, file_path[1000];
DIR *inDir;
struct dirent *inDirent;
inDir = opendir(path);
if (!inDir) {
fprintf(stderr, "Error while searching for bmp files: invalid file path.\\n");
fprintf(stderr, " Unable to op... | 0 |
#include <pthread.h>
struct queue_root *ALLOC_QUEUE_ROOT()
{
struct queue_root *root =
malloc(sizeof(struct queue_root));
pthread_mutex_init(&root->lock, 0);
root->in_queue = 0;
root->out_queue = 0;
return root;
}
void INIT_QUEUE_HEAD(struct queue_head *head)
{
head->next = ((void*)0xCA... | 1 |
#include <pthread.h>
static struct cedrus
{
int fd;
void *regs;
int version;
int ioctl_offset;
struct cedrus_allocator *allocator;
pthread_mutex_t device_lock;
} ve = { .fd = -1, .device_lock = PTHREAD_MUTEX_INITIALIZER };
struct cedrus *cedrus_open(void)
{
if (ve.fd != -1)
return 0;... | 0 |
#include <pthread.h>
pthread_mutex_t commandCentersList[200];
pthread_t workersList[200];
pthread_mutex_t mapRss_lock;
pthread_mutex_t myRss_lock;
int mapRss = 5000;
int myRss = 0;
int myCommandCenters = 0;
int myWorkers = 0;
int myTroops = 0;
void* workingProcess(void* a){
int workerId = (int... | 1 |
#include <pthread.h>
struct measurement {
unsigned tid;
long long real_nsec;
long long user_nsec;
struct measurement *next;
};
static pthread_mutex_t measurements_lock = PTHREAD_MUTEX_INITIALIZER;
struct measurement *perfpiece_measurements = 0;
int perfpiece_active_p = 0;
i... | 0 |
#include <pthread.h>
int i = 0;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t *dlock;
void *
fn1(void *arg) {
struct timespec tout;
struct tm *tmp;
clock_gettime(CLOCK_REALTIME, &tout);
tmp = localtime(&tout.tv_sec);
pthread_t tid = pthread_self();
p... | 1 |
#include <pthread.h>
struct s_word_object {
char *word;
word_object *next;
};
static word_object *list_head;
static pthread_mutex_t list_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t list_data_ready = PTHREAD_COND_INITIALIZER;
static pthread_cond_t list_data_flush = PTHREAD_CO... | 0 |
#include <pthread.h>
pthread_mutex_t frog_mutex;
const char * const FROG[FROG_HEIGHT] =
{
"@@",
"><"
};
const char * const FROG_CLOSE[FROG_HEIGHT] =
{
"^^",
"=="
};
static bool in_bound(const int x, const int y)
{
if(x <= SCR_RIGHT && x >= SCR_LEFT
&& y <= (SCR_BOTTOM-3) && y >= (SCR_... | 1 |
#include <pthread.h>
char char1[671088640], char2[671088640];
long buffer_size, size_div;
struct timeval t;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int th;
void file()
{
printf("\\nGenerating data in the memory...");
int i;
for (i = 0; i < 671088640; ++i)
{
... | 0 |
#include <pthread.h>
void* handle_clnt(void *arg);
void send_msg(int clnt_sock, char *msg, int len);
void error_handling(char *msg);
int clnt_cnt = 0;
int clnt_socks[256];
pthread_mutex_t mutex;
int main(int argc, char *argv[]){
int serv_sock, clnt_sock;
struct sockaddr_in serv_adr, c... | 1 |
#include <pthread.h>
{
int sum;
pthread_mutex_t lock;
}ct_sum;
void *add1(void *cnt)
{
cnt=(ct_sum*)cnt;
pthread_mutex_lock(&(((ct_sum*)cnt)->lock));
int i;
for(i=0;i<50;i++)
{
(*(ct_sum*)cnt).sum+=i;
}
pthread_mutex_unlock(&(((ct_sum*)cnt)->lock)... | 0 |
#include <pthread.h>extern void __VERIFIER_error();
unsigned int __VERIFIER_nondet_uint();
static int top = 0;
static unsigned int arr[800];
pthread_mutex_t m;
_Bool flag = 0;
void error(void)
{
ERROR:
__VERIFIER_error();
return;
}
void inc_top(void)
{
top++;
}
void dec_top(void)
{
top--;
}
int get_top(vo... | 1 |
#include <pthread.h>
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
static int last_written;
static int trial;
static int write_locked;
static int done;
static void* thread(void* idp) {
int id = (intptr_t)idp;
int num_loops... | 0 |
#include <pthread.h>
{
unsigned char valor;
pthread_mutex_t mutex;
pthread_cond_t esperoPar;
} numero_t;
numero_t arreglo[10/2];
pthread_t hilos[10];
int numeroAleatorio(int rango){
return ((rand()) % rango);
}
void arregloAleatorio(){
int i;
for(i = 0; i < (10/2); i++){
arreglo[i... | 1 |
#include <pthread.h>
char MMAP_NAME[] = "racey-mmap.XXXXXX";
const int mmap_size = sizeof(unsigned) * 33;
int MaxLoop = 50000;
int NumProcs;
volatile int startCounter;
pthread_mutex_t threadLock;
unsigned *sig = 0;
union {
char b[64];
int value;
} m[64];
unsigned mix(unsigned i... | 0 |
#include <pthread.h>
pthread_mutex_t s1,s2;
void * thread_func1(void * arg) {
while(1) {
sleep(1);
pthread_mutex_unlock(&s2);
printf("thread1 reached rendezvous point\\n");
pthread_mutex_lock(&s1);
printf("thread1 proceeds\\n");
}
}
void * thread_... | 1 |
#include <pthread.h>
enum mode {
MODE_MB,
MODE_MEMBARRIER,
MODE_COMPILER_BARRIER,
MODE_MEMBARRIER_MISSING_REGISTER,
};
enum mode mode;
struct map_test {
int x, y;
int ref;
int r2, r4;
int r2_ready, r4_ready;
int killed;
pthread_mutex_t lock;
};
static void check_parent_regs(struct ma... | 0 |
#include <pthread.h>
FILE *fichierEdit;
char *tampon;
int tailleTampon;
int indice;
int fin;
char *nomFichier;
pthread_mutex_t mutex;
}Donne;
void
*saisirLesCaracteres(void *parametre);
void
*modifierLeFichier(void *parametre);
char
*agrandirLeTableau(char *letableau,int taille);
void
e... | 1 |
#include <pthread.h>
pthread_mutex_t mutex_leste;
pthread_mutex_t mutex_oeste;
pthread_mutex_t entrada;
pthread_mutex_t turno;
int leste = 0;
int oeste = 0;
void * macaco_leste(void * a){
int i = *((int *) a);
while(1){
pthread_mutex_lock(&turno);
pthread_mutex_lock(&mutex_leste... | 0 |
#include <pthread.h>
int nitems;
struct {
pthread_mutex_t mutex;
int buffer[1000000];
int nput;
int nval;
} shared = { PTHREAD_MUTEX_INITIALIZER };
void *producer(void *param)
{
for(;;) {
pthread_mutex_lock(&shared.mutex);
if (shared.nput >= nitems) {
pthread_mutex_... | 1 |
#include <pthread.h>
struct farmer_data {
int num, to;
};
int passing, crt_dir;
pthread_mutex_t road;
static void *farmer_thread(void *param)
{
struct farmer_data *farmer = (struct farmer_data *) param;
for (;;) {
pthread_mutex_lock(&road);
printf("[FARMER %d] From %s... | 0 |
#include <pthread.h>
const int MAX_KEY = 100000000;
const int IN_LIST = 1;
const int EMPTY_LIST = -1;
const int END_OF_LIST = 0;
struct list_node_s {
int data;
pthread_mutex_t mutex;
struct list_node_s* next;
};
struct list_node_s* head = 0;
pthread_mutex_t head_mutex;
int thread_count... | 1 |
#include <pthread.h>
int numeroDehilos;
double suma=0.0;
long long n=10000000;
void* sumaDepi(void* rank);
int main(int argc, char* argv[])
{
long hilo;
pthread_t* manejadorDehilos;
numeroDehilos=strtol(argv[1], 0, 10);
manejadorDehilos=malloc(numeroDehilos*sizeof(pthread_t));
f... | 0 |
#include <pthread.h>
sem_t empty;
sem_t full;
pthread_mutex_t mutex;
int buffer[10] = { 0 };
int producer_index = 0;
int consumer_index = 0;
int sum = 0;
int producer_id = 0;
int consumer_id = 0;
void *produce() {
int pid = ++producer_id;
while(1) {
sleep(1);
if(sum == 50){
printf("prod... | 1 |
#include <pthread.h>
int saldo_inicial;
pthread_mutex_t mutex_compras;
int main(void) {
pthread_t h1, h2;
saldo_inicial = 100;
pthread_mutex_init(&mutex_compras, 0);
pthread_create(&h1, 0, (void*) compras_mensuales, "Julieta");
pthread_create(&h2, 0, (void*) compras_mensuales, "Leo");
pt... | 0 |
#include <pthread.h>
struct entry {
int key;
int value;
struct entry *next;
};
struct entry *table[5];
int keys[100000];
int nthread = 1;
volatile int done;
pthread_mutex_t mutexes[5];
double
now()
{
struct timeval tv;
gettimeofday(&tv, 0);
return tv.tv_sec + tv.tv_usec / 1000000.0;
... | 1 |
#include <pthread.h>
struct tmq *
tmq_create ()
{
struct tmq *tmq;
if ((tmq = malloc (sizeof (*tmq))) == 0)
return 0;
tmq->size = 0;
tmq->head = 0;
tmq->tail = 0;
pthread_mutex_init (&tmq->lock, 0);
tmq->state = QUEUE_STOPPED;
return tmq;
}
int
... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.