text stringlengths 192 6.24k | label int64 0 1 |
|---|---|
#include <pthread.h>
{
void* ptr;
unsigned int size;
const char* file;
int line;
struct _MtmNode *prev, *next;
}MtmNode;
{
int nodeCnt;
MtmNode *head, *tail;
pthread_mutex_t mutex;
void* (*mallocImpl)(unsigned int size);
void (*freeImpl)(void* ptr);
}MtmHeader;
static MtmHeader *g... | 1 |
#include <pthread.h>
int quitflag;
sigset_t mask;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t wait = PTHREAD_COND_INITIALIZER;
void *
thr_fn(void *arg)
{
int err, signo;
for (;;) {
err = sigwait(&mask, &signo);
if (err != 0) {
err_exit(err, "sigwait failed... | 0 |
#include <pthread.h>
{
int buffer[8];
pthread_mutex_t mutex;
pthread_cond_t notfull;
pthread_cond_t notempty;
int write_pos;
int read_pos;
}pc_st;
pc_st pc;
int init_pc(pc_st *pt, pc_st *attr)
{
if(0 != attr)
{
printf("attr is error value!\\n");
... | 1 |
#include <pthread.h>
buffer_t buffer[5];
int buffer_index;
pthread_mutex_t buffer_mutex;
sem_t full_sem;
sem_t empty_sem;
void insertbuffer(buffer_t value) {
if (buffer_index < 5) {
buffer[buffer_index++] = value;
} else {
printf("Buffer overflow\\n");
}
}
b... | 0 |
#include <pthread.h>
struct thread_arg {
pthread_t tid;
int idx;
} *t_arg;
pthread_mutex_t mutex;
void *start_thread(void *);
void clean_thread(struct thread_arg *);
void cleanup_mutex(void *);
int main()
{
int i, ret;
t_arg = (struct thread_arg *)calloc(7, sizeof(struct thread_arg... | 1 |
#include <pthread.h>
static pid_t linphone_pid = -1;
static pid_t child_process_pid = -1;
static int linphone_work_status =LINPHONE_ON_IDLE;
static pthread_mutex_t linphone_work_status_mutex;
static pthread_t linphone_init_t;
static pthread_t linphone_read_status_t;
static time_t start_linphone_t... | 0 |
#include <pthread.h>
int count=0;
pthread_mutex_t inSem ;
int a,b;
pthread_mutexattr_t myAttr;
void *calcFun(void *data)
{
int sum=0;
pthread_mutex_lock(&inSem);
pthread_mutex_lock(&inSem);
sum=a+b;
printf("Sum=%d\\n",sum);
pthread_mutex_unlock(&inSem);
pthread_mutex_unlock(&inSem);
}
void ... | 1 |
#include <pthread.h>
static pthread_t phil[5];
static pthread_mutex_t forks[5];
short timeout = 1;
void eat(int tid) {
int left = tid, right = (tid + 1) % 5;
int r = 0;
printf("Philosopher %d waiting for fork %d\\n", tid, left);
pthread_mutex_lock(&forks[left]);
if (... | 0 |
#include <pthread.h>
struct message_t{
int data;
int row;
int col;
int command;
struct message_t *next;
} typedef message;
pthread_mutex_t text_ = PTHREAD_MUTEX_INITIALIZER;
int row;
int col;
int view_min;
int view_max;
message* pop(){
}
void push(message* m_)... | 1 |
#include <pthread.h>
int ans = 0, a, b, n, intensity, thread_ans[20], number_of_threads, choice = 1;
int loop_done = 0, granularity, current_iteration = 0;
pthread_mutex_t thread_granularity_lock, thread_ans_lock, thread_current_iteration_lock, thread_ans_array_lock;
int get_start_iteration(... | 0 |
#include <pthread.h>
size_t k;
int file;
char* word;
int N;
pthread_t* threads;
sigset_t mask;
pthread_mutex_t mutex;
pthread_t main_thread_id;
struct thread_args {
int id;
} **args;
void exit_program(int status, char* message) {
if(status == 0) {
printf("%s\\n",message);
} ... | 1 |
#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_to... | 0 |
#include <pthread.h>
struct Triangle{
float base,height;
};
struct SemiCircle{
float radius;
};
struct Rectangle{
float breadth,length;
};
struct Square{
float side;
};
struct Trapezium{
float p1,p2,height;
};
float totalArea=0;
pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER;
void *Area... | 1 |
#include <pthread.h>extern void __VERIFIER_error() ;
int num;
pthread_mutex_t m;
pthread_cond_t empty, full;
void * thread1(void * arg)
{
pthread_mutex_lock(&m);
while (num > 0)
pthread_cond_wait(&empty, &m);
num++;
pthread_mutex_unlock(&m);
pthread_cond_signal(&full);
}
... | 0 |
#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() /(3... | 1 |
#include <pthread.h>
void header();
void tail();
unsigned short crc16(char *data_p, unsigned short length);
unsigned long long int samp;
FILE *vfp;
long double startTime;
void *vlbiData(void *pa)
{
int j=0,ii=0;
int check;
int flag;
double ts;
int err=0;
unsigned long long int... | 0 |
#include <pthread.h>
char buf[200];
int size;
} Message;
pthread_mutex_t mutex= PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond= PTHREAD_COND_INITIALIZER;
Message messages[10];
int next_message= 0;
void broadcast(char *buf, int size) {
Message *msg;
pthread_mutex_lock(&mutex);
msg= ... | 1 |
#include <pthread.h>
pthread_mutex_t thread_count_lock = PTHREAD_MUTEX_INITIALIZER;
int thread_count = 0;
int num_threads = 0;
int initialized = 0;
int global_sense = 1;
int test = 0;
int *local_sense = 0;
int use_busy_wait =0;
int omp_thread_count =4;
int num_barriers = 1;
int busy_wait_c... | 0 |
#include <pthread.h>
struct student{
int id;
int numQuestions;
int questionNum;
};
int totalStudents;
int inOffice, studentZ;
sem_t readyForQuestion, questionWait, answerWait, capacity;
pthread_t professor;
pthread_mutex_t question_lock;
int identification;
void Professor();
void *StartPr... | 1 |
#include <pthread.h>
void printCalEvDebug(struct calendarEvent_t c){
printf("Type: %c, Title: %s, Date: %s, Time: %s, location: %s\\n",c.type, c.calItem.title, c.calItem.date, c.calItem.time, c.calItem.location);
}
int parseEmail(char * buffer, struct calendarEvent_t *c){
char *pch = strtok (... | 0 |
#include <pthread.h>
struct substring_t {
char *s1, *s2;
int n1, n2, start, end, id;
};
int main(int argc, char **argv);
int open_file(FILE **fd, char *fn);
int read_line(FILE *fd, char **result);
void tcount_substrings(substring sub);
void *pcount_substrings(void *args);
int total;... | 1 |
#include <pthread.h>
int fila[5];
int head = 0;
int tail = 0;
sem_t s_item, s_vaga;
pthread_mutex_t s_buffer;
void insertItem(int item){
fila[head] = item;
head = (head + 1) % 5;
}
int removeItem(){
int item = fila[tail];
tail = (tail + 1) % 5;
return item;
}
void *producer(void *id) ... | 0 |
#include <pthread.h>
static pthread_mutex_t *mptr;
int main(int argc, char **argv) {
int fd;
pid_t pid;
key_t key;
int shmid;
char *shm;
pthread_mutexattr_t mattr;
fd = open("/dev/zero", O_RDWR, 0);
mptr = (pthread_mutex_t *)mmap(0, sizeof(pthread_mutex_t), PROT_READ|PROT_WRITE, MAP_S... | 1 |
#include <pthread.h>
static int count = 0;
static pthread_mutex_t countlock = PTHREAD_MUTEX_INITIALIZER;
static int i;
int compile(char *s1, char *s2){
char *filename;
pid_t childpid;
int status;
printf("%s %s\\n", s1, s2);
if((filename = malloc(strlen(s2) + 3)) == 0)
retur... | 0 |
#include <pthread.h>
pthread_mutex_t mutexid;
int commonCounter= 0;
void * thread_function(void *);
int main(void)
{
pthread_t tID_1;
pthread_t tID_2;
if(pthread_mutex_init(&mutexid, 0) != 0 ) {
perror("pthread_mutex_init");
exit(1);
}
if ((pthread_create( &tID_1, 0, thread_f... | 1 |
#include <pthread.h>
static int gsum = 0;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void *thread_func(void *arg)
{
int *start = (int *)arg;
int i;
for(i = *start; i < *start + 100; i++) {
pthread_mutex_lock(&mutex);
gsum += i;
pthread_mutex_unlock(&mute... | 0 |
#include <pthread.h>
struct generic_buffer * init_generic_buffers(int nb_buffers) {
int i;
struct generic_buffer *gb;
struct generic_buffer *next;
gb=malloc(sizeof(struct generic_buffer));
memset(gb,0,sizeof(struct generic_buffer));
next=gb;
for (i=0;i<nb_buffers-1;i++) {
gb=ma... | 1 |
#include <pthread.h>
ssize_t jread(struct jfs *fs, void *buf, size_t count)
{
ssize_t rv;
off_t pos;
pthread_mutex_lock(&(fs->lock));
pos = lseek(fs->fd, 0, 1);
plockf(fs->fd, F_LOCKR, pos, count);
rv = spread(fs->fd, buf, count, pos);
plockf(fs->fd, F_UNLOCK, pos, count);
... | 0 |
#include <pthread.h>
static void do_nothing(void *);
static int cs_add_unsafe(struct cs *set, const void *key);
static int cs_remove_unsafe(struct cs *set, const void *key);
static void *cs_find_unsafe(const struct cs *set, const void *key);
static void *cs_search_unsafe(struct cs *set, const... | 1 |
#include <pthread.h>
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_t threads[OS_MAX_SIMUL_THREADS];
static unsigned numThreads = 0;
static void *
myfunc(void *arg)
{
pthread_mutex_lock(&lock);
numThreads++;
pthread_mutex_unlock(&lock);
pte_osThreadSleep(1000)... | 0 |
#include <pthread.h>
int philID[5];
int currentlyEating = 0;
pthread_mutex_t eatingMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t forks[5];
pthread_cond_t canEat = PTHREAD_COND_INITIALIZER;
pthread_t philosopherThreads[5];
int isEating[5];
int forkOwner[5];
void printTable(){
printf("Eati... | 1 |
#include <pthread.h>
void *Th_piece(pthread_t code_piece, pthread_t numero_machine)
{
pthread_mutex_t mutex_machine = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex_convoyeur = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&mutex_machine);
pthread_mutex_lock(&mutex_convoyeur);
char *mes... | 0 |
#include <pthread.h>
struct mountmanager_struct {
pthread_mutex_t mutex;
pthread_cond_t cond;
unsigned char status;
unsigned char readers;
};
static struct mountmanager_struct mountmanager={PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0};
static struct mount... | 1 |
#include <pthread.h>
struct fq {
struct fq *nxt;
struct dbf *df;
} *fq=0, *fql=0;
struct fqwrk {
struct dbf *df;
char end;
fncwrk fwrk;
pthread_t pt;
pthread_mutex_t mt;
};
void fqadd(struct dbf *df){
struct fq *fi=malloc(sizeof(struct fq));
fi->df=df;
fi->nxt=0;
if(fql){ fql->nxt=... | 0 |
#include <pthread.h>
void* thread_work(void* pvoid)
{
thread_run = 1;
while (thread_run)
{
if (cmd_list != 0 && cmd_list->iAllNum > 0 && cmd_list->iAllNum < MAXLISTSIZE)
{
tagTaskItem *item ;
pthread_mutex_lock(&down_work_mutex);
i... | 1 |
#include <pthread.h>
FILE *debug_file_desc;
pthread_mutex_t debug_mutex;
int log_open(const char *file)
{
if ((debug_file_desc = fopen(file,"w")) == 0){
fprintf(stderr, "Fail to open log file %s\\n", file);
return 1;
}
pthread_mutex_init(&debug_mutex, 0);
return 0;
}
void log_close()
{
... | 0 |
#include <pthread.h>
int
ports_count_bucket (struct port_bucket *bucket)
{
int ret;
pthread_mutex_lock (&_ports_lock);
ret = bucket->count;
bucket->flags |= PORT_BUCKET_NO_ALLOC;
pthread_mutex_unlock (&_ports_lock);
return ret;
}
| 1 |
#include <pthread.h>
static char *root;
static int workers;
static int trials;
static int record_absolute;
static struct timeval asbolute_start;
static pthread_mutex_t worker_sync_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t worker_sync_cond = PTHREAD_COND_INITIALIZER;
static volatile... | 0 |
#include <pthread.h>
int NUM_READERS = 0;
int NUM_WRITERS = 0;
int SHARED_VARIABLE = 0;
int reader_has_priority = 0;
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t write_ok = PTHREAD_COND_INITIALIZER;
pthread_cond_t read_ok = PTHREAD_COND_INITIALIZER;
void *writer (void *param);
voi... | 1 |
#include <pthread.h>
cell_t** prev;
cell_t** next;
int maxth, steps, cont = 0, size;
pthread_mutex_t m;
pthread_barrier_t barreira;
cell_t ** allocate_board (int size) {
cell_t ** board = (cell_t **) malloc(sizeof(cell_t*)*size);
for (int i = 0; i < size; i++)
board[i] = (cell_t *) mall... | 0 |
#include <pthread.h>
int w, h;
v2df zero = { 0.0, 0.0 };
v2df four = { 4.0, 4.0 };
v2df nzero;
double inverse_w;
double inverse_h;
char *whole_data;
int y_pick;
pthread_mutex_t y_mutex = PTHREAD_MUTEX_INITIALIZER;
static void * worker(void *_args) {
char *data;
double x, y;
int ... | 1 |
#include <pthread.h>
void
*inqueue_new(char *sender, char *reciever, char *data, int cmd,
ssize_t sender_size, ssize_t reciever_size, ssize_t data_size)
{
struct inqueue_s *inque = malloc(sizeof(struct inqueue_s));
assert(inque);
inque->sender = malloc_copy(sender, sender_size);
inque->reci... | 0 |
#include <pthread.h>
pthread_mutex_t m[5];
pthread_mutex_t m2;
int s = 1000;
void * functie(void* arg){
int id = *(int*)arg;
printf("Filozoful %d se aseaza la masa \\n", id);
int gata = 0;
do{
int st = (id == 0 ? 5 -1 : id - 1);
int dr = id;
pthread_mutex_lock(&m[st]);
if(pthread... | 1 |
#include <pthread.h>
void *Train();
void * Passenger();
int timesToRun, passLeft,noBoard, capacity, flag;
pthread_mutex_t entry, board, end, ready, ride;
int main (int argc, char* argv[]){
int i, noPass, thrCheck;
pthread_t *pasThread;
noBoard=0;
flag=0;
printf ("How many passengers... | 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>
int
sem_init(sem_t* s, int pshared, unsigned int val)
{
int r;
(void)pshared;
s->s_val = val;
pthread_mutex_init(&s->s_lock, 0);
if (0 != (r = pthread_cond_init(&s->s_cond, 0)))
return r;
return 0;
}
int
sem_wait(sem_t* s)
{
pthrea... | 0 |
#include <pthread.h>
static pthread_mutex_t s_mutex;
static pthread_cond_t s_cond;
static int s_i;
static const char* err_to_str(int errnum)
{
switch (errnum) {
case 0: return "success";
case EBUSY: return "EBUSY";
case EINVAL: return "EINVAL";
default: return "?";
}
}
static vo... | 1 |
#include <pthread.h>
int main(int argc, char **argv)
{
if (nps_main_init(argc, argv)) {
return 1;
}
if (nps_main.fg_host) {
pthread_create(&th_flight_gear, 0, nps_flight_gear_loop, 0);
}
pthread_create(&th_display_ivy, 0, nps_main_display, 0);
pthread_create(&th_main_loop,... | 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>
pthread_mutex_t udp_send_mutex;
struct udp_conn socket_conn;
char *double_to_char(double u_value,char u_arr[]){
sprintf(u_arr, "%f", u_value);
}
int udp_init(){
pthread_mutex_init(&udp_send_mutex,0);
return udp_init_client(&socket_conn,9999,"192.168.0.1");
}
int s... | 0 |
#include <pthread.h>
pthread_mutex_t lock;
pthread_cond_t cond;
int oddDone = 1;
int shared_var;
int cnt = 10;
void* print_even(void *foo) {
while (cnt > 0) {
pthread_mutex_lock(&lock);
if (!oddDone)
pthread_cond_wait(&cond, &lock);
printf("cond = %d evenTh... | 1 |
#include <pthread.h>
int a[100];
int g_index = 0;
int min;
pthread_mutex_t mutex1, mutex2;
void *min_routine(void *nothing)
{
int l_index;
do
{
pthread_mutex_lock(&mutex1);
l_index = g_index;
g_index++;
pthread_mutex_unlock(&mutex1);
if (l_index < 100)
{
if(*(a + l_index)... | 0 |
#include <pthread.h>
pthread_t t1, t2;
pthread_mutex_t m1, m2;
int i1, i2;
} program;
void *thread1(void *data)
{
program *p = (program *)data;
struct timespec wait;
wait.tv_sec = 1;
wait.tv_nsec = 0;
printf("Starting t1\\n");
while(42)
{
pthread_mutex_lock(&p->m1);
... | 1 |
#include <pthread.h>
const void *ident;
pthread_cond_t cond;
int32_t ref;
int32_t sig;
}tsleep_entry_t;
static tsleep_entry_t sleepTable[16];
static pthread_mutex_t tsleep_mutex;
static void timeout_ticks_to_abs_timespec(clock_t ticks, struct timespec *tmspec)
{
t... | 0 |
#include <pthread.h>
{
char name[20];
char number[20];
struct phone *next;
}PHONE;
pthread_mutex_t mutex;
PHONE *tail = 0;
PHONE *head[26];
void
read_insert(char *book)
{
FILE *fp;
char number5[20];
char name5[20];
fp=fopen(book, "r");
if(fp==... | 1 |
#include <pthread.h>
int value;
pthread_mutex_t mutex;
pthread_cond_t cond;
} sema_t;
int in;
int out;
int space[4];
sema_t mutext_sema;
sema_t empty_buffer_sema;
sema_t full_buffer_sema;
}buff;
buff buffer1, buffer2;
void sema_init(sema_t *sema, int value)... | 0 |
#include <pthread.h>
int
pthread_mutex_getprioceiling(pthread_mutex_t *mutexp, int *prioceiling)
{
pthread_mutex_t mutex = *mutexp;
if (mutex->prioceiling == -1)
return (EINVAL);
*prioceiling = mutex->prioceiling;
return (0);
}
int
pthread_mutex_setprioceiling(pthread_mutex_t *mutexp, in... | 1 |
#include <pthread.h>
static int fd = 0;
static pthread_mutex_t rw_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t fd_lock = PTHREAD_MUTEX_INITIALIZER;
void pci_init()
{
pthread_mutex_lock(&fd_lock);
if (!fd) {
if (alt_up_pci_open(&fd, "/dev/alt_up_pci0")) {
pthread_mu... | 0 |
#include <pthread.h>
int dev_lkgdb_fd = -1;
unsigned int lkgdb_cmd;
static void *lkgdb_kwork (void*);
static pthread_mutex_t lkgdb_lock;
static pthread_cond_t lkgdb_cond;
int lkgdb_init()
{
pthread_t lkgdb_tid;
dev_lkgdb_fd = open_dev();
if (dev_lkgdb_fd < 0) {
return -1;
... | 1 |
#include <pthread.h>
ssize_t Readline(int sockd, void *vptr, size_t maxlen)
{
ssize_t n, rc;
char c, *buffer;
buffer = vptr;
for ( n = 1; n < maxlen; n++ )
{
if ( (rc = read(sockd, &c, 1)) == 1 )
{
*buffer++ = c;
if ( c == '\\n' )
break;
}
else if ( rc ==... | 0 |
#include <pthread.h>
pthread_t threads[10 + 1];
int waitTime = 0;
sem_t customerSem;
sem_t barberSem;
pthread_mutex_t barberShopLock = PTHREAD_MUTEX_INITIALIZER;
void cut_hair(int ID){
printf("\\t\\tThe Barber is cutting hair!\\n");
int rand_num = rand() % 3;
sleep(2);
printf... | 1 |
#include <pthread.h>
struct glob{
int a;
int b;
}obj;
pthread_mutex_t r_mutex;
void *threadFunc1(void *arg){
printf("thread1 has created, tid = %lu\\n",pthread_self());
printf("thread1 locked the semaphore\\n");
pthread_mutex_lock(&r_mutex);
obj.a = 10;
sleep(5);
pthread_exit(0);... | 0 |
#include <pthread.h>
struct name_type_conv{
enum MON_CONTROLLER_TYPE type;
char dev_name[128];
};
static struct name_type_conv n2t[] = {
{MT_MAIN, "main"},
{MT_EXPANDER1, "expander-1"},
{MT_EXPANDER2, "expander-2"},
{MT_EXPANDER3, "expander-3"},
{MT_EXPANDER4, "expander-4"}
};
void name2ty... | 1 |
#include <pthread.h>
int w, h;
v2df zero = { 0.0, 0.0 };
v2df four = { 4.0, 4.0 };
v2df nzero;
double inverse_w;
double inverse_h;
char *whole_data;
int y_pick;
pthread_mutex_t y_mutex = PTHREAD_MUTEX_INITIALIZER;
static void * worker(void *_args) {
char *data;
double x, y;
int ... | 0 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_cond_t cond;
int sillas[5]= {0, 0, 0, 0, 0};
int buscarSilla() {
pthread_mutex_lock(&mutex);
for (;;) {
if (sillas[0] == 0 && sillas[1] == 0 && sillas[4] == 0){
sillas[0] = 1;
pthread_mutex_unlock(&m... | 1 |
#include <pthread.h>
pthread_mutex_t verrou;
sem_t sem1,sem2,sem3;
int medium_executed = 0;
int inversion = 0;
void Thread1()
{
sem_wait(&sem1);
pthread_mutex_lock(&verrou);
printf("Thread_1 : HIGH Pritority\\n");
sem_post(&sem3);
pthread_mutex_unlock(&verrou);
if(medium_execut... | 0 |
#include <pthread.h>
int arr[10];
int gindex = 0;
int sum = 0;
pthread_mutex_t sum_mutex;
void *sumf(void *t){
int lindex = 0;
int partial_sum = 0;
while(lindex < 10 ) {
pthread_mutex_lock(&sum_mutex);
lindex = gindex;
gindex++;
pthread_mutex_unlock(&sum_mutex);
partial_sum += arr[... | 1 |
#include <pthread.h>
int atomic_fprintf(FILE * pFile, const char * format, ...)
{
pthread_mutex_lock(&fprintf_mutex);
va_list args;
__builtin_va_start((args));
int ret = vfprintf(pFile, format, args);
;
pthread_mutex_unlock(&fprintf_mutex);
return ret;
}
FILE * fil... | 0 |
#include <pthread.h>
int readersInQueue = 0;
int writersInQueue = 0;
int readersInLibrary = 0;
int writersInLibrary = 0;
pthread_mutex_t varMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t readerMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t libraryMutex = PTHREAD_MUTEX_INITIALIZER;
unsigned... | 1 |
#include <pthread.h>
static int sigNum = 0;
pthread_t hdlthreadSignalProcessor = 0;
pthread_mutex_t signalMutex = PTHREAD_MUTEX_INITIALIZER;
static int staticSimpleSigaction(int signum, sighandler_t act)
{
struct sigaction sigConf = {};
if (0 == act)
{
errno = EIO;
return -1;
}
sigempt... | 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 *t)
{
int i;
long my_id = (long)t;
for (i=0; i<10; i++) {
pthread_mutex_lock(&count_mutex);
count++;
if (count == 12)... | 1 |
#include <pthread.h>
struct msg {
struct msg *next;
int num;
};
void print_list(struct msg *head);
struct msg *head;
struct msg *tail;
pthread_cond_t has_product = PTHREAD_COND_INITIALIZER;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
void *consumer(void *p)
{
struct msg *mp;
for (... | 0 |
#include <pthread.h>
char* key;
char* value;
size_t value_len;
struct hash_item** pprev;
struct hash_item* next;
} hash_item;
hash_item* hash[1024];
pthread_mutex_t hash_mutex[1024];
hash_item* hash_get(const char* key, int create) {
unsigned b = string_hash(key) % 1024... | 1 |
#include <pthread.h>
pthread_mutex_t user_lock;
struct user_info {
char user[32];
char pass[32];
unsigned char pril;
pthread_mutex_t lock;
int ref;
unsigned char used;
} user_db[100];
int mgr_cnt;
void inline get_word(char* line, char* word)
{
while (*line != ' ' && *line != '\\t' && *l... | 0 |
#include <pthread.h>
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
int ti = 0;
struct node {
int n_number;
struct node *n_next;
} *head = 0;
static void cleanup_handler(void *arg)
{
printf("cleanup handler of second thread.... | 1 |
#include <pthread.h>
void *Process(void *p);
void Receive(int *connfd);
void Reply(int *connfd, char *file);
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int main()
{
int sfd;
struct sockaddr_in addr;
sfd = socket(PF_INET, SOCK_STREAM, 0);
if (sfd == -1)
{
printf("Initialize socke... | 0 |
#include <pthread.h>
{
pthread_mutex_t pid_mutex;
pid_t pid;
}pid_data;
int set_priority(int priority){
int policy;
struct sched_param param;
if(priority < 1 || priority > 63) return -1;
pthread_getschedparam(pthread_self(),&policy,¶m);
param.sched_priority = priority;
return pthre... | 1 |
#include <pthread.h>
unsigned int __VERIFIER_nondet_uint();
static int top=0;
static unsigned int arr[(5)];
pthread_mutex_t m;
_Bool flag=(0);
void error(void)
{
ERROR: ;
goto ERROR;
return;
}
void inc_top(void)
{
top++;
}
void dec_top(void)
{
top--;
}
int get_top(void)
{
ret... | 0 |
#include <pthread.h>
void * start_routine1(void *arg);
void * start_routine2(void *arg);
pthread_mutex_t lock;
int i;
int
main(int argc, char const *argv[])
{
pthread_t tid1, tid2;
pthread_mutex_init(&lock,0);
if (pthread_create(&tid1, 0,start_routine1,0) != 0)
perror("pthread_create");
i... | 1 |
#include <pthread.h>
pthread_mutex_t LOCK;
pthread_mutex_t TRIGGER;
pthread_cond_t COND;
volatile unsigned int cs_count = 0;
void * function(void *id){
int t_id = *(int *)id;
pthread_mutex_lock(&TRIGGER);
pthread_mutex_unlock(&TRIGGER);
pthread_mutex_lock(&LOCK);
if (... | 0 |
#include <pthread.h>
void* threadFunction( void* rank );
pthread_mutex_t mutex;
double globalSum = 0.0;
int main( void )
{
double startTime, finishTime;
pthread_mutex_init( &mutex, ( pthread_mutexattr_t* ) 0 );
pthread_t* threadHandles = ( pthread_t* )malloc( 8 * sizeof( pthread_t ) );
GE... | 1 |
#include <pthread.h>
pthread_mutex_t sumLock = PTHREAD_MUTEX_INITIALIZER;
int *vk;
int *vTrue;
pthread_t thread;
int state;
int toVector;
int startPosition;
int endPosition;
}Boundary_t;
void* sumThread(void* bd){
Boundary_t *boundary = (Boundary_t*)bd;
int localSum=0;
for(int... | 0 |
#include <pthread.h>
int stoj = 0;
int cakaju = 0, volneMiesta = 10;
int vsetciCakaju = 0;
int pocetPiv = 0;
pthread_mutex_t mutexPivo = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutexCakanie = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condPivo = PTHREAD_COND_INITIALIZER;
pthread_cond_t condCa... | 1 |
#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,thread2,(void *)0);
pthread_create(&t_b,0,threa... | 0 |
#include <pthread.h>
sem_t sem;
int semVal;
pthread_mutex_t mut;
pthread_cond_t condC;
pthread_cond_t condA;
void utiliserPont(int type){
if (type == 1){
sem_wait(&sem);
sem_getvalue(&sem, &semVal);
}
else{
int i = 0;
for(i=0; i<3; i++){
sem_wait(&sem);
sem_getvalue(&se... | 1 |
#include <pthread.h>
pthread_cond_t adultBoardOahu;
pthread_cond_t kidsBoardOahu;
pthread_cond_t onBoat;
pthread_cond_t onMolo;
int boatLoc;
int kidsOnBoard;
int adultsOnBoard;
int adultGoes;
int canBoard;
void init() {
pthread_mutex_init(&lock, 0);
pthread_cond_init(&allReady, 0);
pthrea... | 0 |
#include <pthread.h>
static char *self = "018";
static char *set = "01689";
int count = 0;
pthread_mutex_t output_mutex;
void real_output(int len, char *current){
int mid = len >> 1,
tail = len - 1,
i;
char c;
for(i = 0; i <= mid; ++i){
switch(current[i]){
case '0':
c = '0';
... | 1 |
#include <pthread.h>
int MyTurn = 0;
{
pthread_mutex_t *lock;
int id;
int size;
int iterations;
char *s;
int nthreads;
} Thread_struct;
void *infloop(void *x)
{
int i, j, k;
Thread_struct *t;
t = (Thread_struct *) x;
for (i = 0; i < t->iterations; i++)
{
pthread_mutex_loc... | 0 |
#include <pthread.h>
void Test();
void Test_Mutex1();
void Test_Mutex2();
int main(void)
{
Test_Mutex2();
return 0;
}
void * Fun1(void * param)
{
int * p = (int *)param;
int n = 10;
for(int i = 0; i < n; i++)
{
*p += i;
usleep(1000);
}
pr... | 1 |
#include <pthread.h>
enum Colour
{
blue = 0,
red = 1,
yellow = 2,
Invalid = 3
};
const char* ColourName[] = {"blue", "red", "yellow"};
const int STACK_SIZE = 32*1024;
const BOOL TRUE = 1;
const BOOL FALSE = 0;
int CreatureID = 0;
enum Colour doCompliment(enum Colour c1, enum Colo... | 0 |
#include <pthread.h>
int N ;
int D;
int P;
pthread_t *threads;
pthread_mutex_t lock;
float** a ;
float* b ;
float* x ;
double time_start, time_end;
void* do_work(void*);
main (int argc, char *argv[] ) {
if(argc != 3) {printf("wrong number of arguments") ; exit(2) ;}
N = atoi(argv[1]);
... | 1 |
#include <pthread.h>
pthread_mutex_t lock2;
int main(int argc, char* argv[]) {
int id;
SharedMem *ptr;
id = shmget (atoi(argv[1]), 0, 0);
if (id == -1){
perror ("child shmget failed");
exit (1);
}
ptr = shmat (id, (void *) 0, 1023);
if (ptr == (void ... | 0 |
#include <pthread.h>
static inline void can_execute(struct userid *id, struct ext2inode *ino)
{
}
static inline void can_read(struct userid *id, struct ext2inode *ino)
{
}
static inline void can_write(struct userid *id, struct ext2inode *ino)
{
}
int check_name(char *dest, uint8_t nlen... | 1 |
#include <pthread.h>
double sum=0.0, a[1000000];
pthread_mutex_t sum_mutex;
void *do_work(void *tid)
{
int i, start, *mytid, end;
double mysum=0.0;
mytid = (int *) tid;
start = (*mytid * 1000000 / 4);
end = start + 1000000 / 4;
printf ("Thread %d doing iterations %d to %d\\n",*... | 0 |
#include <pthread.h>
const long NUM_PHILOSOPHERS = 5;
pthread_mutex_t chopstick_mutex[5];
void* grab_chopsticks(void* rank);
int main(void)
{
long i, j;
pthread_t* threads = (pthread_t*)malloc(NUM_PHILOSOPHERS * sizeof(pthread_t));
for(i = 0; i < NUM_PHILOSOPHERS; ++i)
{
... | 1 |
#include <pthread.h>
char user_input;
int user_move = -1;
pthread_mutex_t mutex;
pthread_t thr_read, thr_right, thr_left, thr_quit;
void err_msg(int err_type, const char* string)
{
printf("%s with a error code of: %d\\n", string, err_type);
}
void* user_go_left(void *args){
if(user... | 0 |
#include <pthread.h>
enum {
KEY_OK,
KEY_FAIL,
DATA_OK,
DATA_FAIL
};
struct server_answ {
unsigned code;
};
struct login_data {
unsigned id;
char key[65];
};
struct meteo_data {
float temp;
float hum;
};
static struct {
pthread_mutex_t mutex;
struct tcp_server server;
struct databa... | 1 |
#include <pthread.h>
int g_num;
pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t g_cond = PTHREAD_COND_INITIALIZER;
void* thread_add(void *param)
{
sleep(1);
for (;;) {
pthread_mutex_lock(&g_mutex);
printf("thread 1 lock,");
g_num++;
printf("add num: %d... | 0 |
#include <pthread.h>
void UpdateAttitude( );
void ReadAttitude( );
static void ( *ThreadFunctions[ NUM_THREADS ] ) =
{ UpdateAttitude,
ReadAttitude };
int main( int argc, char** argv )
{
pthread_t threads[ NUM_THREADS ];
int thread_args[ NUM_THREADS ];
in... | 1 |
#include <pthread.h>
int event_filter(const struct inotify_event *event)
{
int n = 0;
if ((event->mask) & IN_IGNORED)
n = 1;
if (!((event->mask) & IN_ISDIR) && ((event->mask) & IN_CREATE))
n = 1;
if (strchr((event->name), ... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.