text stringlengths 192 6.24k | label int64 0 1 |
|---|---|
#include <pthread.h>
static struct timespec timer;
static int timerset;
static unsigned int flags;
static pthread_cond_t cond;
static pthread_mutex_t mtx;
static pthread_t thr;
static void (*threadfunc)(void);
static void *thread(void *param){
(void)param;
threadfunc();
return 0;... | 1 |
#include <pthread.h>
struct memory_list {
struct memory_list *next;
};
struct chunk_list {
struct chunk_list *next;
struct memory_list *data;
};
static struct memory_list * _free_list[((16384)/(8))] = {0};
static pthread_mutex_t _free_list_locks[((16384)/(8))];
static stru... | 0 |
#include <pthread.h>extern void __VERIFIER_error() ;
static int iTThreads = 2;
static int iRThreads = 1;
static int data1Value = 0;
static int data2Value = 0;
pthread_mutex_t *data1Lock;
pthread_mutex_t *data2Lock;
void lock(pthread_mutex_t *);
void unlock(pthread_mutex_t *);
void *funcA(... | 1 |
#include <pthread.h>
struct db
{
uint32_t num_keys;
uint32_t *keys;
uint32_t *num_values;
uint32_t **values;
pthread_mutex_t lock;
};
struct db *
db_open (const char *path, const int parallel)
{
struct db *d = malloc (sizeof *d);
(void) path;
(void) parallel;
if (0 != d)
... | 0 |
#include <pthread.h>
int philosopherMonitor = 1;
int philosopherState[5];
int philosopherFood = 1;
pthread_t philosopherThread[5];
pthread_mutex_t philosopherMonitorMutex;
pthread_cond_t philosopherReadyResource;
void *create_philosopher(void *number);
void pickup_forks(int,int,int);
void r... | 1 |
#include <pthread.h>
static FILE* log_fp = 0;
static int log_count = 0;
static pthread_mutex_t log_lock = PTHREAD_MUTEX_INITIALIZER;
int log_open(const char* name, const char* mode)
{
pthread_mutex_lock(&log_lock);
if (!log_fp) {
log_fp = fopen(name, mode);
if (!log_fp) ... | 0 |
#include <pthread.h>
const int MAX = 10;
int thread_number = -1;
pthread_mutex_t mutex;
char _getch();
void* thread_print(void*);
int main()
{
char ch;
pthread_t thread[MAX];
pthread_mutex_init(&mutex, 0);
while(1)
{
ch = _getch();
switch(ch)
{
case '+':
threa... | 1 |
#include <pthread.h>
static struct {
char error_str[512];
char __zero;
} io_util;
void io_sleep_to(struct ds_timespec *abstime)
{
pthread_mutex_t tmp_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t tmp_cond = PTHREAD_COND_INITIALIZER;
struct timespec time;
time.tv_sec = abstime->tv_... | 0 |
#include <pthread.h>
extern int makethread(void *(*)(void *), void *);
struct to_info {
void (*to_fn)(void *);
void *to_arg;
struct timespec to_wait;
};
void clock_gettime(struct timespec *tsp)
{
struct timeval tv;
gettimeofday(&tv, 0);
tsp -> tv_sec = tv.tv_sec;
... | 1 |
#include <pthread.h>
pthread_mutex_t ready_queue_mutex;
pthread_barrier_t init_barrier;
int* marked;
int id;
struct ready_queue *next;
};
struct ready_queue *head;
struct ready_queue *tail;
struct ready_queue *empty_queue;
int lower_bound;
int upper_bound;
int k;
int work_ready;
};
struc... | 0 |
#include <pthread.h>
pthread_mutex_t forks[5];
pthread_t phils[5];
void *philosopher (void *id);
int food_on_table ();
void get_fork (int, int, char *);
void down_forks (int, int);
pthread_mutex_t foodlock;
pthread_mutex_t nforks;
pthread_cond_t cond;
int sleep_seconds = 0;
int succeed = 0;
... | 1 |
#include <pthread.h>
int volatile total = 0;
int thread_count;
char* messages[100];
pthread_mutex_t total_mutex;
pthread_cond_t cond_var;
void Usage(char prog_name[]);
void *Thread_work(void* rank);
int main(int argc, char* argv[]) {
long i;
pthread_t* thread_handles;
if (argc != 2)... | 0 |
#include <pthread.h>
int start;
int end;
int *arr;
} thread_data_t;
static int g_swapped;
pthread_barrier_t barrier;
pthread_mutex_t mutex;
int *generate_data(int size) {
int *p = malloc(sizeof(int) * size);
int i;
for(i = 0; i < size; i++) {
p[i] = rand() % 1000;
}
retu... | 1 |
#include <pthread.h>
int thread_count = 3;
char input[1] = "\\0";
char buffer[100] = "\\0";
int file_read_complete = 0;
int file_process_complete = 0;
int end_of_buffer_index = 0;
int buffer_ready = 0;
pthread_mutex_t mutex_t1_t2 = PTHREAD_MUTEX_INITIALIZER;
int remove_last_word(char* str... | 0 |
#include <pthread.h>
void **data;
size_t head, tail, used, cap;
sem_t empty_sem, filled_sem;
pthread_mutex_t buffer_mutex;
pthread_cond_t buffer_ready;
} RB_LOCK;
RB_LOCK *rb_lock_init(size_t capacity) {
if (capacity < 1) return 0;
RB_LOCK *rb = malloc(sizeof(RB_LOCK))... | 1 |
#include <pthread.h>
sem_t barber_ready;
sem_t cust_ready;
pthread_mutex_t access_seats = PTHREAD_MUTEX_INITIALIZER, dummy_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t barber_busy = PTHREAD_COND_INITIALIZER;
int free_seats = 5;
void barber()
{
while(1)
{
sem_wait(&cust_ready);
p... | 0 |
#include <pthread.h>
struct product_cons
{
int buffer[5];
pthread_mutex_t lock;
int readpos,writepos;
pthread_cond_t notempty;
pthread_cond_t notfull;
}buffer;
void init (struct product_cons *p)
{
pthread_mutex_init(&p->lock,0);
pthread_cond_init(&p->notempty,0);
pthread_cond_init(&p-... | 1 |
#include <pthread.h>
{
int id;
int tieneTabaco;
int tienePapel;
int tieneFosforo;
int estaFumando;
int estaProduciendo;
int idProduccion;
} Fumador;
{
int hayTabaco;
int hayPapel;
int hayFosforo;
} Mesa;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALI... | 0 |
#include <pthread.h>
int mediafirefs_chmod(const char *path, mode_t mode)
{
printf("FUNCTION: chmod. path: %s\\n", path);
(void)path;
(void)mode;
struct mediafirefs_context_private *ctx;
ctx = fuse_get_context()->private_data;
pthread_mutex_lock(&(ctx->mutex));
... | 1 |
#include <pthread.h>
pthread_cond_t condition = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void* threadAlarme (void* arg);
void* threadCompteur (void* arg);
int main (void)
{
pthread_t monThreadCompteur;
pthread_t monThreadAlarme;
pthread_create (&mo... | 0 |
#include <pthread.h>
char buffer[8000];
int bufCnt=0;
int numThreads=0;
void * readFile(void * fname)
{
int offset = numThreads*2000;
pthread_mutex_t lock_g;
pthread_mutex_lock(&lock_g);
int threadNum = numThreads++;
int readCnt=0;
char symbol='?';
FILE *f = fopen( (char*)fname,... | 1 |
#include <pthread.h>
int tcp_log = 1;
int imcp_log = 0;
pthread_mutex_t stdout_lock = PTHREAD_MUTEX_INITIALIZER;
void logger_ipv6(char *buffer) {
struct ip6_hdr *hdr = (struct ip6_hdr *) buffer;
struct in6_addr *src = &hdr->ip6_src;
struct in6_addr *dst = &hdr->ip6_dst;
... | 0 |
#include <pthread.h>
int in = 0;
int out = 0;
int buff[10] = {0};
sem_t empty_sem;
sem_t full_sem;
pthread_mutex_t mutex;
int product_id = 0;
int prochase_id = 0;
void print()
{
int i;
for(i = 0; i < 10; i++)
printf("%d ", buff[i]);
printf("\\n");
}
void *product()
{
int... | 1 |
#include <pthread.h>
void* funProd(void *arg);
void* funPosr(void *arg);
void* funKons(void *arg);
struct bufor
{
int dane[16];
int licznik;
int we;
int wy;
pthread_cond_t *zmWar;
pthread_mutex_t *semafor;
};
int czytaj(bufor_t *buf);
void zapisz(bufor_t *buf, int wartosc);
void 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_con... | 1 |
#include <pthread.h>
int n=0;
pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t qready = PTHREAD_COND_INITIALIZER;
void* thread_func(void* arg) {
int param = (int) arg;
char c='1'+param;
int ret, i=0;
for(; i < 10; i++) {
pthread_mutex_lock(&mylock);
... | 0 |
#include <pthread.h>
struct msg {
struct msg *next;
int num;
};
struct msg *head;
pthread_cond_t has_product = PTHREAD_COND_INITIALIZER;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
void *consumer(void *p) {
struct msg *mp;
for (;;) {
pthread_mutex_lock(&lock);
while (head == 0){
... | 1 |
#include <pthread.h>
pthread_mutex_t lock;
int count;
int next_index;
void * chunk(void * thread_id){
int id=*(int *) thread_id;
int counter=0;
int i, start=0;
while(1){
pthread_mutex_lock(&lock);
start=next_index;
next_index+=100;
pthread_mutex_unlock(&lock);... | 0 |
#include <pthread.h>
struct AHRS ahrs;
struct GPSDATA gps;
pthread_mutex_t mutex_ahrs;
pthread_mutex_t mutex_gps;
void *threadFunc(void *ptr)
{
struct msg_packet packet;
int ret,msgid;
while(1){
msgid = msgget(MSGKEY,IPC_EXCL);
if(msgid<0)
{
continue;
}
ret = msgrcv(msgid,&packe... | 1 |
#include <pthread.h>
pthread_mutex_t livelock_001_glb_A;
pthread_mutex_t livelock_001_glb_B;
static int x,y;
void *mythreadA(void *pram)
{
while(1)
{
pthread_mutex_lock(&livelock_001_glb_A);
x=x+1;
pthread_mutex_unlock(&livelock_001_glb_A);
int status=pthread_mutex_trylock(&livel... | 0 |
#include <pthread.h>
struct philosopher {
int lchopstick_id;
int rchopstick_id;
char *name;
};
int chopstick_list[5];
struct philosopher nerds[5];
pthread_mutex_t miyagi;
void think(struct philosopher n) {
int slptm = (rand()%20) + 1;
printf("%s is thinking for %d seconds! Go %s!\\n", n.n... | 1 |
#include <pthread.h>
void reader_function(void);
void writer_function(void);
int buffer_has_item = 0;
pthread_mutex_t mutex;
main()
{
pthread_t reader;
pthread_mutex_init(&mutex, 0);
pthread_create( &reader, 0, (void*)&reader_function, 0);
writer_function();
}
void writer_function... | 0 |
#include <pthread.h>
void do_one_thing(int *);
void do_another_thing(int *);
void do_wrap_up(int, int);
void mon(int );
int r1 = 0, r2 = 0;
int i;
struct proc_time *timer;
pthread_mutex_t printfLock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t xx = PTHREAD_MUTEX_INITIALIZER;
main(void)
{
... | 1 |
#include <pthread.h>
int contador;
pthread_mutex_t mutex;
sem_t semaforo_productor;
void agregar(char c);
void quitar();
void * productor()
{
while(1)
{
char c = 'a' + rand()%24;
agregar(c);
usleep(1000);
}
}
void * consumidor()
{
while(1)
{
quitar();
usleep(1000);... | 0 |
#include <pthread.h>
static pthread_t thread;
static pthread_cond_t cond;
static pthread_mutex_t mutex;
static int flag = 1;
void * thr_fn(void * arg)
{
struct timeval now;
struct timespec outtime;
pthread_mutex_lock(&mutex);
while (flag) {
printf("*****\\n");
gettimeofday(&now, 0... | 1 |
#include <pthread.h>
int buffer[3];
int add = 0;
int rem = 0;
int num = 0;
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t c_cons = PTHREAD_COND_INITIALIZER;
pthread_cond_t c_prod = PTHREAD_COND_INITIALIZER;
void *producer (void *param);
void *consumer (void *param);
int main(in... | 0 |
#include <pthread.h>
int lista[10];
int inicio_cola;
int fin_cola;
} lista_circular;
static lista_circular almacen;
pthread_mutex_t mutex_cola;
pthread_cond_t condicion_vacio,condicion_lleno;
void productor()
{
int aux=0;
while (1) {
sleep(1);
aux = aux+1;... | 1 |
#include <pthread.h>
void enqueue(struct vder_queue *q, struct vde_buff *b)
{
pthread_mutex_lock(&q->lock);
if (!q->may_enqueue(q, b)) {
free(b);
pthread_mutex_unlock(&q->lock);
return;
}
b->next = 0;
if (!q->head) {
q->head = b;
q->tail = b;
} else {
q->tail->next = b;
... | 0 |
#include <pthread.h>
pthread_mutex_t counter_mutex = PTHREAD_MUTEX_INITIALIZER;
int fd, dp;
int allsize = 0;
int counter = 0;
int temp = 0;
void *thread_copy(void *arg)
{
int len;
int buf = (int)arg;
int str[4096];
pthread_mutex_lock(&counter_mutex);
allsize = counter;
lseek(fd, allsize, 0... | 1 |
#include <pthread.h>
uint32_t max_size;
const char * log_dir;
char * log_file;
pthread_mutex_t log_mutex;
uint8_t to_file;
uint8_t to_sys;
static void log_rotate() {
int buf_len;
char newfile[2048 +1];
buf_len = strlen(log_file) + 30;
struct timeval tv;
gettimeofday(&tv, ... | 0 |
#include <pthread.h>
pthread_t tid [2];
int mine [5][5];
int minetot,p1,p2;
char namap1[50], namap2[50];
pthread_mutex_t lock;
void isiranjau(int num)
{
int i,j;
if (num % 4 == 0){
i = (num/4)-1;
j = (num%4)-1;
}
else{
i = num/4;
j = num%4;
}
if (!mine[i][j]) minetot++;
mine [i][j]... | 1 |
#include <pthread.h>
void mission(float x_cons, float y_cons, float z_cons, float angle_cons, float * pitch_cmd, float * roll_cmd, float * angular_speed_cmd, float * vertical_speed_cmd)
{
pthread_mutex_lock(&mutex_mission);
if(newCoordXY!=0) {
x = loca_x;
y = loca_y;
newCoordXY = 0;
}
... | 0 |
#include <pthread.h>
int udp_send(void* arg)
{
int* status = arg;
printf("udp sending starts.\\n");
char* rec_cmd = "rec -q -t raw -b 16 -c 1 -e s -r 44100 -";
FILE* rec_fp;
if ((rec_fp = popen(rec_cmd, "r")) == 0) fail("failed to rec...\\n");
int s = udp_socket[99];
unsigned char... | 1 |
#include <pthread.h>
int redpack = 20;
int N = 10;
pthread_t thread[10];
pthread_mutex_t mut;
int count = 0;
int who = 1;
int my_rand(int s, void * arg)
{
int *p = (int *)arg;
time_t ts;
srand((unsigned int)time(&ts) + *p);
int a = 0;
while(a == 0)
{
a = ... | 0 |
#include <pthread.h>
const unsigned int ARRAY_SEED = 332484;
const double EPSILON = 1.0;
unsigned long ARRAY_DIMENSIONS;
unsigned long NUM_THREADS;
unsigned long loopIt;
pthread_mutex_t epsilon_mutex;
pthread_barrier_t barrier;
double **array;
double **resultArray;
double highestChange = 0.0... | 1 |
#include <pthread.h>
struct _char_channel{
char queue[100];
int front;
int back;
int MAX_SIZE;
int size;
bool poisoned;
pthread_mutex_t lock;
pthread_cond_t write_ready;
pthread_cond_t read_ready;
};
int _init_char_channel(struct _char_channel *channel){
if... | 0 |
#include <pthread.h>
extern int diosock;
extern int verbose;
extern pthread_mutex_t dio_comm_lock;
void *DIO_ready_controlprogram(struct ControlProgram *arg)
{
struct ROSMsg s_msg,r_msg;
ros_msg_init(&s_msg);
ros_msg_init(&r_msg);
ros_msg_set_command(&s_msg,CtrlProg_READY,"ctrlprog_ready"... | 1 |
#include <pthread.h>
const int MAX_KEY = 100000000;
struct list_node_s {
int data;
struct list_node_s* next;
};
struct list_node_s* head = 0;
int thread_count; int total_ops;
double insert_percent; double search_percent; double delete_percent;
pthread_mutex_t mutex;
pthread_mutex_t count_m... | 0 |
#include <pthread.h>
int g_buffer[5];
unsigned short in = 0;
unsigned short out = 0;
unsigned short produce_id = 0;
unsigned short consume_id = 0;
sem_t g_sem_full;
sem_t g_sem_empty;
pthread_mutex_t g_mutex;
pthread_t g_thread[2 + 2];
void *consume(void *arg)
{
int i;
int num = (int)a... | 1 |
#include <pthread.h>
long long d_to_proc=0;
int tCount=0;
char *outDir="/tmp";
struct linux_dirent {
long d_ino;
off_t d_off;
unsigned short d_reclen;
char d_name[];
};
struct qEnt {
char *dName;
struct qEnt* next;
};
struct qEnt* head = 0;
struct qEnt* tail = 0;
pthread_mutex_t ... | 0 |
#include <pthread.h>
int **m1;
int **m2;
int **m3;
int n;
int numT;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condizione = PTHREAD_COND_INITIALIZER;
void stampa(int **m){
for (int i=0;i<n;i++){
for (int j=0;j<n;j++){
printf("%d\\t",m[i][j]);
}
printf("\\n");
}
}
void *fun... | 1 |
#include <pthread.h>
unsigned int _memUsed = 0;
struct LinkedListNode * _CreateNode (void);
struct LinkedListNode * _DeleteNode (struct LinkedListNode *target);
void _LockList (struct List *target);
void _UnlockList (struct List *target);
void _LockList (struct List *target) {
pthread_mut... | 0 |
#include <pthread.h>
struct test_struct {
int disconnected_count;
int connected_count;
int server_fgalive_count;
int client_fgalive_count;
int client_confirmed_count;
sem_t *sem;
pthread_mutex_t *mutex;
};
static int
server_callback (void *arg, struct fgevent *fge... | 1 |
#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... | 0 |
#include <pthread.h>
struct mq_attr attr;
FILE *logFile;
void *LoggerThread(void *args)
{ printf("%s\\n","Logger created");
uint32_t data_to_log;
uint32_t ret;
uint32_t bytes_read;
LogMsg *logmsg3;
printf("Log file create status - %d,\\n", create_log_file(&logFile, "some"));
if(create_log... | 1 |
#include <pthread.h>
int main(int argc, char* argv[]){
pthread_t Les_Threads[2];
int delai[2], i = 0;
void Une_Tache (void *arg);
if (argc != 3) {
printf("Utilisation : %s delai_1 delai_2 !\\n", argv[0]);
return 1;
}
for (i = 0; i < 2 ; i++){
delai[i] = atoi(argv[i+1... | 0 |
#include <pthread.h>
pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
void prepare(void)
{
printf("preparing locks...\\n");
pthread_mutex_lock(&lock1);
pthread_mutex_lock(&lock2);
}
void parent(void)
{
printf("parent unlocking ... | 1 |
#include <pthread.h>
struct msgreg_t {
int mtype;
short rvport;
};
struct msggetnode_t {
int mtype;
};
struct node {
struct sockaddr_in address;
long port;
int del;
};
struct listmsg_t {
int mtype;
struct node nodeList[10];
};
struct recvmsg_t {
i... | 0 |
#include <pthread.h>
struct CRYPTO_dynlock_value
{ pthread_mutex_t mutex;
};
void sigpipe_handle(int x)
{
}
static pthread_mutex_t *mutex_buf;
static struct CRYPTO_dynlock_value *dyn_create_function(const char *file, int line)
{ struct CRYPTO_dynlock_value *value;
value = (struct CRYPTO_dynl... | 1 |
#include <pthread.h>
double x;
double y;
} vec2;
vec2 position;
vec2 velocity;
double mass;
} planet;
int num_threads;
int num_planets;
int num_timesteps;
int output;
int portion;
vec2** local_forces;
int counter;
pthread_mutex_t mutex;
pthread_cond_t cond_var;
vec2*... | 0 |
#include <pthread.h>
int nitems;
struct {
pthread_mutex_t mutex;
int buff[10000000];
int nput;
int nval;
} shared={
PTHREAD_MUTEX_INITIALIZER
};
void consume_wait(int i){
for(;;){
pthread_mutex_lock(&shared.mutex);
if(i<shared.nput){
pthread_mutex_unlock(&shared.mutex);
return;
... | 1 |
#include <pthread.h>
static char* output_string = 0;
static pthread_mutex_t output_lock;
static int initialized = 0;
static pthread_t thread;
static int has_battery = 0;
static void* query_battery_thread() {
FILE *fp;
if( output_string == 0 ) {
output_string = calloc( 32, si... | 0 |
#include <pthread.h>
pthread_mutex_t mutex[3] = {
PTHREAD_MUTEX_INITIALIZER,
PTHREAD_MUTEX_INITIALIZER,
PTHREAD_MUTEX_INITIALIZER
};
void *lock_forward (void *arg)
{
int i, iterate, backoffs;
int status;
for (iterate = 0; iterate < 10; iterate++) {
... | 1 |
#include <pthread.h>
pthread_mutex_t mutex1, mutex2, mutex3;
void * th1(){
while(1){
pthread_mutex_lock(&mutex1);
printf("1\\n");
fflush(stdout);
sleep(1);
pthread_mutex_unlock(&mutex2);
}
}
void * th2(){
while(1){
pthread_mutex_lock(&mutex2);
printf("2\\n");
fflush(stdout);
... | 0 |
#include <pthread.h>
{
void *(*process)(void *arg);
void *arg;
struct worker *next;
} CThread_worker;
{
pthread_mutex_t queue_lock;
pthread_cond_t queue_ready;
CThread_worker *queue_head;
int shutdown;
pthread_t *threadid;
int max_thread_num;
int cur_... | 1 |
#include <pthread.h>
struct sigfd_compat_info
{
sigset_t mask;
int fd;
};
static void *sigwait_compat(void *opaque)
{
struct sigfd_compat_info *info = opaque;
sigset_t all;
sigfillset(&all);
pthread_sigmask(SIG_BLOCK, &all, 0);
while (1) {
int sig;
i... | 0 |
#include <pthread.h>
int ticketcount = 20;
pthread_mutex_t lock;
void *salewind1(void *args)
{
while(1)
{
pthread_mutex_lock(&lock);
if(ticketcount > 0)
{
printf("windows1 start sale ticket! the ticket is :%d\\n", ticketcount);
sleep(3);
ticketcount--;
printf("sale tic... | 1 |
#include <pthread.h>
int count = 0;
pthread_mutex_t count_mutex;
pthread_cond_t count_threshold_cv;
void *inc_count(void *t)
{
int j,i;
double result=0.0;
long my_id = (long)t;
for (i=0; i < 10; i++) {
pthread_mutex_lock(&count_mutex);
count++;
if (count == 12) {
... | 0 |
#include <pthread.h>
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex3 = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t pourLire = PTHREAD_COND_INITIALIZER;
pthread_cond_t pourEcrire = PTHREAD_COND_INITIALIZER;
void put(i... | 1 |
#include <pthread.h>
pthread_t geigerThread;
int geigerThreadID;
extern int geigerCount;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int count = 0;
int openGPIO(unsigned int gpio){
int fd, value;
char buf[64];
snprintf(buf, sizeof(buf), "echo %i >/sys/class/gpio/export", gpio);
s... | 0 |
#include <pthread.h>
struct ozy_ringbuffer* ozy_output_buffer;
pthread_mutex_t ozy_output_buffer_mutex;
int ozy_put_bytes=0;
int ozy_get_bytes=0;
struct ozy_ringbuffer* new_ozy_ringbuffer(int n) {
struct ozy_ringbuffer* buffer;
fprintf(stderr,"new_ozy_ringbuf... | 1 |
#include <pthread.h>
void *printInfo(void *arg);
void *getDate(void *arg);
void *getStocks(void *arg);
void *updateTime(void *arg);
void *getVolume(void *arg);
char *weekrussian(int num);
char *monthrussian(int num);
char *dayrussian(int num);
char *day;
char *weekday;
char *month;
i... | 0 |
#include <pthread.h>
pthread_mutex_t mutex;
int resource = 5;
void *allocator(void *param);
int main(void)
{
int i;
pthread_t tids[10];
pthread_mutex_init(&mutex, 0);
for (i = 0; i < 10; i++)
{
pthread_create(&tids[i], 0, allocator, i+1);
}
for (i = 0; i < 10; i++)
{
pthread_join(tids... | 1 |
#include <pthread.h>
pthread_mutex_t sleep_lock_001_glb_mutex_;
pthread_mutex_t *sleep_lock_001_glb_mutex = &sleep_lock_001_glb_mutex_;
void sleep_lock_001_glb_mutex_lock () {}
void sleep_lock_001_glb_mutex_unlock () {}
int sleep_lock_001_glb_data = 0;
void* sleep_lock_001_tsk_001 (void *pram)
... | 0 |
#include <pthread.h>
void print_motor_status();
void print_MC_faults();
void testMotorForward(long dur);
void testMotorFast(long dur);
void genericThrottleTest(char* name,long dur,int speed, int throttle);
int main(int argc, char *argv[])
{
MC_Setup();
long dur=5000;
testFunc funcArray[(... | 1 |
#include <pthread.h>
void generate(int n);
void Read(int n);
void *func1(void *arg);
void *func2(void *arg);
void *func3(void *arg);
void calculate();
void resultToFile();
int A[1000];
int B[20][1000];
int prefix_sum[20][1000]={0};
pthread_t tids[20][1000];
pthread_mutex_t mutex;
int n;
stru... | 0 |
#include <pthread.h>
int piao = 100;
pthread_mutex_t mut;
void* tprocess1(void* args){
int a = 0;
while(1){
pthread_mutex_lock(&mut);
if(piao>0){
sleep(1);
piao--;
printf("xiancheng 1----------------»¹Ê£%dÕÅÆ±\\n",piao);
... | 1 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int comida = 6;
struct filosofo{
char * nombre;
int cantComida;
struct tenedor * ten1;
struct tenedor * ten2;
};
struct tenedor{
int estado;
};
void * comer( void * h1)
{
struct filosofo * fil;
... | 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 = (struct foo*)malloc(sizeof(struct fo... | 1 |
#include <pthread.h>
pthread_mutex_t mutex;
int counter=0;
void thread1(void *arg);
void thread2(void *arg);
int main(int argc, char *argv[])
{
pthread_t id1,id2;
if(pthread_mutex_init(&mutex, 0) != 0) {
perror("Mutex initialization");
exit(1);
}
if(pthread_create(&id1,0,(void *)thre... | 0 |
#include <pthread.h>
pthread_mutex_t resource[100];
pthread_t task0, task1, task2;
int selfid[1000];
int lselfid = 0;
int self2id(int self){
int i = 0;
for (i = 0; i < lselfid; ++i)
{
if(self == selfid[i])return i;
}
selfid[i] = self;
lselfid ++;
return i;
}
int lock2id(int ... | 1 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond;
char buf[1024] = { 0 };
void *write_thread(void *arg)
{
while (1) {
pthread_mutex_lock(&mutex);
printf(">");
fgets(buf, sizeof(buf), stdin);
pthread_cond_signal(&cond);
pthread_mutex_u... | 0 |
#include <pthread.h>
void miframman_init(struct miframman *ram, void *start_dram, size_t size_pool)
{
pthread_mutex_init(&ram->lock, 0);
ram->num_blocks = size_pool / MIFRAMMAN_BLOCK_SIZE;
if (ram->num_blocks == 0) {
SLSI_ERR_NODEV("Pool size < BLOCK_SIZE\\n");
return;
}
if (ram-... | 1 |
#include <pthread.h>
void *thread_func1(void *ptr);
void *thread_func2(void *ptr);
void *log_thread(void *ptr);
char buf[256]={0};
pthread_mutex_t buf_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t buf_empty = PTHREAD_COND_INITIALIZER;
int main() {
pthread_t t1, t2, t_log;
int ret;
... | 0 |
#include <pthread.h>
void * enano (void * arg);
void mina (int noEnano);
void cerrarCocina (int ids);
void comer (int noEnano);
void salirACaminar ();
void * blancanieves (void * arg);
pthread_t * enanos;
pthread_mutex_t mutexSillas = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutexEnanos = ... | 1 |
#include <pthread.h>
int last_threadID = 1;
int threadRunCounts[5] = {0};
pthread_mutex_t myTurnMutex;
pthread_cond_t myTurnSignal;
int checkArray(int arrayToCheck[]) {
for (int i = 0; i < 5; i++){
int x = threadRunCounts[i];
printf("Thread number %d has been run %d times\\n", i, x);
if(... | 0 |
#include <pthread.h>
{
int value;
struct cell *next;
}
*cell;
{
int length;
cell first;
cell last;
}
*list;
list add (int v, list l)
{
cell c = (cell) malloc (sizeof (struct cell));
c->value = v;
c->next = 0;
if (l == 0){
l = (list) malloc (sizeof (struct list)... | 1 |
#include <pthread.h>
int nitems;
struct {
pthread_mutex_t mutex;
int buff[10000000];
int nput;
int nval;
} shared={
PTHREAD_MUTEX_INITIALIZER
};
struct{
pthread_mutex_t mutex;
pthread_cond_t cond;
int nready;
}ready={PTHREAD_MUTEX_INITIALIZER,
PTHREAD_COND_INITIALIZER
};
void consume_... | 0 |
#include <pthread.h> TOUCH_START = 0,
TOUCH_DRAG = 1,
TOUCH_RELEASE = 2,
TOUCH_HOLD = 3,
TOUCH_REPEAT = 4
} TOUCH_STATE;
int draw_dot(int x, int y)
{
if(x < 0 || y < 0){
return -1;
}
pthread_mutex_lock(&gUpdateMutex);
gr_color(0, 0, 255, 255);
gr_fill(x, y, 2, 2);
pthread_mutex_unlock(&gUpdateMutex);
... | 1 |
#include <pthread.h>
volatile int n;
pthread_mutex_t me;
sem_t s;
} barrier_t;
barrier_t b, b2;
int n, k;
int numer, denom;
volatile double result = 1;
void* numerator(void *);
void* denominator(void *);
int main(int argc, char **argv) {
pthread_t numer_tid, denom_tid;
... | 0 |
#include <pthread.h>
extern struct connection svr_conn[];
void net_add_close_func(
int sd,
void (*func)(int))
{
pthread_mutex_lock(svr_conn[sd].cn_mutex);
if (svr_conn[sd].cn_active != Idle)
svr_conn[sd].cn_oncl = func;
pthread_mutex_unlock(svr_conn[sd].cn_mutex);
}
| 1 |
#include <pthread.h>
struct entry {
struct entry *next;
const char *word;
pthread_mutex_t mtx;
int count;
};
struct bucket {
pthread_mutex_t mtx;
struct entry *entries;
} H[10007];
unsigned hash(const char *s)
{
unsigned h = 10007 ^ ((unsigned)*s++ << 2);
unsigned len = 0;
whi... | 0 |
#include <pthread.h>
int occurrences = 0;
{
char *character;
char *file;
} s_request;
void *scanFile( s_request *request );
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void main ( int argumentCount, char *argumentVariables[] )
{
if (argumentCount > 50)
{
... | 1 |
#include <pthread.h>
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
int val;
struct node * next;
} node_t;
node_t * head = 0;
void insert(int val) {
node_t *new_node = malloc(sizeof(node_t));
new_node->val = val;
pthread_mutex_lock(&lock);
if (head == 0) {
head = new_node;
} e... | 0 |
#include <pthread.h>
int flag = 1;
pthread_mutex_t mutex;
pthread_cond_t condvar;
void *tf(void *param){
int i = 0;
while (i < 1000000000000000000) {
pthread_mutex_lock(&mutex);
if (flag == 2) {
write(STDOUT_FILENO, "2", 1);
i++;
flag = 1;
pthread_cond_signal(&condvar);
}... | 1 |
#include <pthread.h>
{
int
*a;
int
*b;
int sum;
int veclen;
} DOTDATA;
DOTDATA dotstr;
pthread_t callThd[3];
pthread_mutex_t mutexsum;
void *dotprod(void *arg)
{
int i, start, end, len;
long offset;
int mysum, *x, *y;
offset = *(long *)arg;
len = dotstr.veclen;
start = offset*len;
en... | 0 |
#include <pthread.h>
long m,sum;
int n;
pthread_mutex_t mutex;
void* thread(void* i){
long ssum = 0;
printf("ii = %d\\n",(int)i);
for(long j = m/n*(int)i + 1; j <= m/n*((int)i+1) ; j++){
printf("j = %ld\\n",j);
ssum+=j;
}
pthread_mutex_lock(&mutex);
su... | 1 |
#include <pthread.h>
double *A;
double *B;
double *C;
int n;
double matrix_norm;
double *b;
double *c;
int num_of_columns;
pthread_mutex_t *mutex;
} matrix_slice;
void *matrix_slice_multiply(void *arg){
matrix_slice *slice = arg;
int i, j;
cblas_dgemm(CblasRowMajor, CblasNoT... | 0 |
#include <pthread.h>
pthread_t thread1, thread2;
pthread_mutex_t kill_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t operacao_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t fazer_operacao = PTHREAD_COND_INITIALIZER;
void *functionCount1() {
int thread_status = 0;
thread_sta... | 1 |
#include <pthread.h>
pthread_mutex_t mutex[10];
void *new_start_routine( void * arg ) {
for (int i = 1; i < 10; i += 2) {
pthread_mutex_lock(mutex + i);
}
for (int i = 1; i < 10; i += 2) {
pthread_mutex_lock(mutex + i - 1);
pthread_mutex_unlock(mutex + i - 1);
printf("CHILD\\n");
... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.