text stringlengths 192 6.24k | label int64 0 1 |
|---|---|
#include <pthread.h>
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg);
int pthread_join(pthread_t thread, void **retval);
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
long iteration;
int NTHREADS;
long nfot;
unsigned int seed1;... | 1 |
#include <pthread.h>
struct msm_frame* get_frame(struct fifo_queue* queue)
{
struct msm_frame *p = 0;
do{}while(0);
pthread_mutex_lock(&(queue->mut));
do{}while(0);
if (queue->front) {
struct fifo_node *node = dequeue (queue);
do{}while(0);
if (node) {
p = (struct msm_fr... | 0 |
#include <pthread.h>
void * thread_fcn(void * thread_arg);
int myID;
int num_threads;
double step;
double *sum_p;
pthread_mutex_t *lock_p;
} thread_args_t;
int main(int argc, char *argv[]) {
double start_time, end_time;
double pi;
double sum = 0.0;
d... | 1 |
#include <pthread.h>
int fd_ip = -1;
int fd_ip_server;
pthread_mutex_t mutex_fd_ip;
char bf_ip[256] = "";
void *setup_ip(void *arg){
struct sockaddr_in addr_server = { 0 }, addr_client = { 0 };
pthread_t thread_read;
int portno, fd_temp;
printf("Port No: ");
scanf("%d",&portno);
fd_i... | 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)... | 1 |
#include <pthread.h>
struct cometData {
int sendCount;
struct cometData *next_cd;
long long ch_id;
pthread_mutex_t ch_mutex;
pthread_cond_t ch_cond;
char *httpDomain;
long long extraData;
} *cdList = 0;
pthread_mutex_t cdlMutex;
char * callHomeScript = "<script type=\\"text/javascript\\... | 0 |
#include <pthread.h>
pthread_t thread_id;
int thread_num,id;
int copy_COUNT_GLOBAL;
char color[6];
int condition;
} ThreadData;
pthread_mutex_t jet_mutex;
int CONDITION_JET ,COUNT_GLOBAL;
void jetFly(ThreadData *jet){
pthread_mutex_lock(&jet_mutex);
if(C... | 1 |
#include <pthread.h>
pthread_mutex_t m;
int s;
void* thr1(void* arg)
{
int l = __VERIFIER_nondet_int(0, 1000);
l = 4;
pthread_mutex_lock (&m);
s = l;
__VERIFIER_assert (s == l);
pthread_mutex_unlock (&m);
return 0;
}
int main()
{
s = __VERIFIER_nondet_int(0, 1000);
p... | 0 |
#include <pthread.h>
int flag = 0;
pthread_mutex_t m;
pthread_cond_t c = PTHREAD_COND_INITIALIZER;
void * thread1(void *p)
{
for(;;){
pthread_mutex_lock(&m);
while ( flag == 0)
pthread_cond_wait(&c, &m);
pthread_mutex_unlock(&m);
if (flag ){
write(1, p, 1);
sl... | 1 |
#include <pthread.h>
static pthread_once_t g_init = PTHREAD_ONCE_INIT;
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t g_lcd_lock = PTHREAD_MUTEX_INITIALIZER;
static struct light_state_t g_notification;
static struct light_state_t g_battery;
struct led_data... | 0 |
#include <pthread.h>
void *thread_function_Even(void *arg);
void *thread_function_Odd(void *arg);
void *Read_Buff(void *arg);
int run_now = 1;
int i = 0;
sem_t bin_sem1;
sem_t bin_sem2;
int Buffer[50];
char message[] = "Hello World";
pthread_mutex_t work_mutex;
int main(void)
{
int res;... | 1 |
#include <pthread.h>
struct job {
int id;
struct job *next;
};
void process_job (struct job *one_job)
{
printf("Thread_%d is process job %d\\n", (int)pthread_self (), one_job->id);
}
pthread_mutex_t job_queue_mutex = PTHREAD_MUTEX_INITIALIZER;
void *thread_func (void *data)
{
... | 0 |
#include <pthread.h>
pthread_mutex_t mutex;
struct timespec timeout;
int use_timeout;
void *run(void *arg) {
int retcode;
printf("in child: sleeping\\n");
sleep(2);
if (use_timeout) {
retcode = pthread_mutex_timedlock(&mutex, &timeout);
} else {
retcode = pthread_mutex_lock(&... | 1 |
#include <pthread.h>
{
int p_index;
int c_index;
int num[2];
}BUFFER;
BUFFER buf;
pthread_mutex_t pc_mutex;
pthread_cond_t pc_condp, pc_condc;
void * producer(void * nul)
{
int i;
for (i = 1; i <= 10; ++i)
{
pthread_mutex_lock(&pc_mutex);
while(buf.p_index == buf.c_index)
... | 0 |
#include <pthread.h>
pthread_mutex_t m[3];
int printed=0;
void* print_message ( void* str ){
int i = 0;
int k = 1;
int err;
pthread_mutex_lock( &m[2]);
if (printed) pthread_mutex_unlock(&m[0]);
for ( i = 0; i < 4*3; i++ ){
if (err=pthread_mutex_lock(&m[k]))
... | 1 |
#include <pthread.h>
char* fila[FILA_MAX];
pthread_mutex_t mutex;
sem_t consumidor;
int index_produtor;
int index_consumidor;
int working=1;
void * thread_code (void * args);
char* myfiles[NB_FILES];
void init_myfiles () {
int i,n,counter;
int numbers[NB_FILES];
char* tmp;
srand... | 0 |
#include <pthread.h>
int thread_count_;
int **dp_;
int city_count_;
pthread_mutex_t *muts;
void* thread_subcal (void* rank);
int main (int argc, char* argv[])
{
long thread_i;
pthread_t* thread_handle_pt;
double start, end;
if (argc < 2) {
printf("Please indicate ... | 1 |
#include <pthread.h>
pthread_t thread1, thread2, thread3;
pthread_mutex_t lock1, lock2, lock3;
void *workOne(void *arg) {
pthread_mutex_lock(&lock1);
usleep(1000);
pthread_mutex_lock(&lock2);
usleep(1000);
pthread_mutex_unlock(&lock2);
pthread_mutex_unlock(&lock1);
... | 0 |
#include <pthread.h>
int main(int argc, char *argv[]) {
int rc;
joblist_t *job;
pthread_t udsserverThread;
pthread_t tcpserverThread;
pthread_t announceThread;
pthread_t discoverThread;
pthread_t expireThread;
openlog("peerslave", LOG_PID | LOG_PERROR, LOG_USER);
setlogmask... | 1 |
#include <pthread.h>
size_t k;
int file;
char* word;
int N;
pthread_t* threads;
volatile sig_atomic_t *thread_complete;
pthread_mutex_t mutex;
struct thread_args {
int id;
} **args;
void exit_program(int status, char* message) {
if(status == 0) {
printf("%s\\n",message);
} e... | 0 |
#include <pthread.h>
struct foo* fh[29];
pthread_mutex_t hashlock = PTHREAD_MUTEX_INITIALIZER;
struct foo
{
int f_count;
int id;
pthread_mutex_t f_lock;
struct foo* next;
};
struct foo* foo_alloc(int id)
{
struct foo* fp;
int idx;
if ((fp = malloc(sizeof(struct foo... | 1 |
#include <pthread.h>
extern pthread_mutex_t global_data_mutex;
void update_temp_data (int temp_fd) {
char temp[6];
float realtemp;
int read_rc;
assert(-1 != temp_fd);
memset(temp, 0, 6);
lseek(temp_fd,0,0);
read_rc = read(temp_fd,temp,5);
if(0 > read_rc)
{
close(temp_f... | 0 |
#include <pthread.h>
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
void *thread()
{
long i = 0;
unsigned int count = 0;
struct timeval start, end;
float time_cost;
gettimeofday(&start, 0);
for ( i; i < 10000000; i++ )
{
pthread_mutex_lock(&lock);
... | 1 |
#include <pthread.h>
pthread_mutex_t mta, mtb;
pthread_t a, b;
void* funca(void *arg) {
int i;
for(i = 0; i < 10; ++ i) {
pthread_mutex_lock(&mta);
printf("Thread A = %d\\n", (int)pthread_self());
pthread_mutex_unlock(&mtb);
}
return 0;
}
void* funcb(v... | 0 |
#include <pthread.h>
extern struct th *assign_r;
extern struct queue *start;
extern pthread_mutex_t mut_que;
extern pthread_mutex_t mut_th_status;
extern pthread_mutex_t mutex_assign;
extern pthread_cond_t *thread_wake;
extern pthread_cond_t new_in_que;
extern pthread_cond_t served;
extern int ... | 1 |
#include <pthread.h>
int npoints[4] = {100, 500, 1000, 2000};
static int num_circle_count = 0;
pthread_mutex_t circle_lock = PTHREAD_MUTEX_INITIALIZER;
float random_gen(float from, float to) {
int r = rand();
float fr = (float) r / (float) 32767;
fr = fr * (to - from);
fr = fr + from;
... | 0 |
#include <pthread.h>extern void __VERIFIER_error() ;
unsigned int __VERIFIER_nondet_uint();
static int top = 0;
static unsigned int arr[400];
pthread_mutex_t m;
_Bool flag = 0;
void error(void)
{
ERROR:
__VERIFIER_error();
return;
}
void inc_top(void)
{
top++;
}
void dec_top(void)
{
... | 1 |
#include <pthread.h>
pthread_mutex_t x;
pthread_t t1[10],t2[10];
sem_t db;
int rc;
void init()
{
pthread_mutex_init(&x,0);
sem_init(&db,1,1);
rc=0;
}
void reader()
{
printf("\\nReader trying to enter ");
pthread_mutex_lock(&x);
rc++;
if(rc==1)
sem_wait(&db);
printf("\\n%d reader inside",r... | 0 |
#include <pthread.h>
{
int data;
struct my_list* next;
}product_list;
product_list *head = 0;
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t need_product = PTHREAD_COND_INITIALIZER;
void InitList(product_list *list)
{
if(0 != head)
{
list->next = 0;
li... | 1 |
#include <pthread.h>
enum pt_state {
SETUP,
IDLE,
JOB,
DIE
};
int task;
int size;
enum pt_state state;
pthread_cond_t work_cond;
pthread_mutex_t work_mtx;
} pt_info;
pthread_t threads[3][2];
pt_info shared_info[3][2];
void *task_type1(void *arg)
{
pt_info *info = (pt_info *) arg;
... | 0 |
#include <pthread.h>
int fillCount = 0, emptyCount = 5;
pthread_mutex_t buffer_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t buffer_not_full = PTHREAD_COND_INITIALIZER;
pthread_cond_t buffer_not_empty = PTHREAD_COND_INITIALIZER;
sem_t buffer_sem;
void produce(void* i);
void consume(void* i... | 1 |
#include <pthread.h>
pthread_t broadcast_thread;
pthread_mutex_t broadcast_cond_mtx = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t broadcast_cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t latest_entry_mtx = PTHREAD_MUTEX_INITIALIZER;
int started = 0;
struct log_entry latest_entry = {0};
long last_b... | 0 |
#include <pthread.h>
pthread_mutex_t corda = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t decisao = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t turno = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int contA = 50;
int contB = 50;
int escolhaA;
int escolhaB;
voi... | 1 |
#include <pthread.h>
pthread_mutex_t m;
pthread_cond_t cond;
char str[100];
bool str_available;
void* producer(void* arg ) {
while (1) {
char buf[sizeof str];
fgets(buf, sizeof buf, stdin);
pthread_mutex_lock(&m);
strncpy(str, buf, sizeof str);
str_avai... | 0 |
#include <pthread.h>
int minimum_value, partial_list_size;
pthread_mutex_t minimum_value_lock;
{
int readers;
int writer;
pthread_cond_t readers_proceed;
pthread_cond_t writer_proceed;
int pending_writers;
pthread_mutex_t read_write_lock;
} mylib_rwloc... | 1 |
#include <pthread.h>
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static unsigned count;
void* thread_func(void* arg)
{
unsigned i;
for (i = 0; i < 1000; ++i) {
void* ptr;
ptr = malloc(22816);
memset(ptr,... | 0 |
#include <pthread.h>
pthread_mutex_t action_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t action_cond = PTHREAD_COND_INITIALIZER;
int cancel_operation = 0;
void
restore_coocked_mode(void* dummy)
{
system("stty -raw echo");
}
void*
read_user_input(void* data)
{
int c;... | 1 |
#include <pthread.h>
int recordSize = 1024;
int threadsNr;
char *fileName;
int fd;
int numOfRecords;
int creatingFinished = 0;
char *word;
int rc;
int someonefound = 0;
int detachedNr = 0;
pthread_key_t key;
pthread_t *threads;
int *wasJoin;
pthread_mutex_t mutexForRecords = PTHREAD_MUTEX_INI... | 0 |
#include <pthread.h>
int main(int argc, char *argv[]) {
int fd = 0;
int ret = 0;
battleship_shmem_t* dataPtr;
pthread_mutexattr_t myattr;
fd = shm_open("/myshmemobject", O_RDWR | O_CREAT, S_IRWXU);
if (fd == -1) {
printf("error creating the shared memory object.\\n");
exit(1);
}
... | 1 |
#include <pthread.h>
static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER;
int atomic_int_get(volatile int *ptr)
{
int res;
pthread_mutex_lock(&atomic_lock);
res = *ptr;
pthread_mutex_unlock(&atomic_lock);
return res;
}
void atomic_int_set(volatile i... | 0 |
#include <pthread.h>
void* writer(void*);
void* reader(void*);
unsigned *addr;
pthread_mutex_t mutex_write;
pthread_mutex_t mutex_read;
pthread_cond_t cv;
main(int argc, char * argv[]) {
int fd;
pthread_t reader_tid, writer_tid;
fd = shm_open("/mymem", O_RDWR | O_CREAT, 0777);
if ... | 1 |
#include <pthread.h>
int data[(3)];
int start;
int end;
int count;
} pool_t;
int items_to_produce = 20;
pthread_mutex_t mtx;
pthread_mutex_t mtx_item_prod;
pthread_cond_t cond_nonempty;
pthread_cond_t cond_nonfull;
pool_t pool;
void init_pool(pool_t * pool);
void push(pool_t * ... | 0 |
#include <pthread.h>
int flag=0;
int n;
int i=13;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condizione = PTHREAD_COND_INITIALIZER;
void *scrittore (void *p){
int fd = open ("file.txt",O_WRONLY);
char *buff =malloc(sizeof(int));
while(i<n){
pthread_mutex_lock(&mutex)... | 1 |
#include <pthread.h>
static int num = 0;
static pthread_mutex_t mut_num = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t cond_num = PTHREAD_COND_INITIALIZER;
struct arg{
int i;
};
void cal(int i, void* p);
static void* func(void *p);
int main(int argc, const char *argv[])
{
int err, i;
... | 0 |
#include <pthread.h>
{
char *message;
}MESSAGE;
MESSAGE myMessage;
pthread_t tid[2];
int messageIndex;
pthread_mutex_t lock;
void* readPerson1(void *arg)
{
int i = 0;
char tempChar;
FILE *input = fopen("Person1", "r");
tempChar = getc(input);
while (tempChar != EOF)
{
pthread_mutex_l... | 1 |
#include <pthread.h>
pthread_mutex_t glock;
pthread_cond_t gcond;
void *release(void *tmp) {
pthread_cond_signal(&gcond);
pthread_cond_signal(&gcond);
}
void *test(void *tmp) {
pthread_mutex_lock(&glock);
printf("%s main lock getpid:%d\\n", "18:45:34", getpid());
printf("%s main lock syscal... | 0 |
#include <pthread.h>
long min(long a, long b) {
if(a > b) return b;
else return a;
}
struct input {
long num;
long cT;
};
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
long divisor = 2;
long curThread = 0;
long timecount = 0;
void *createThread(void *input) {
struct input *in = input;
... | 1 |
#include <pthread.h>
pthread_mutex_t Mutex;
int Hours, Minutes, Seconds;
void init_clock(void)
{
Hours = 11;
Minutes = 59;
Seconds = 30;
pthread_mutex_init(&Mutex, 0);
}
void increment_time(void)
{
pthread_mutex_lock(&Mutex);
Seconds++;
if (Seconds > ... | 0 |
#include <pthread.h>
int shared = 0;
pthread_mutex_t mutex_shared;
void * increment(void *arg)
{
int i;
for(i=0; i<1000; i++)
{
pthread_mutex_lock(&mutex_shared);
shared++;
pthread_mutex_unlock(&mutex_shared);
}
pthread_exit(0);
}
int main (int argc, char *argv[])
{
... | 1 |
#include <pthread.h>
pthread_mutex_t candado;
pthread_cond_t producido;
pthread_cond_t consumido;
char buffer[8];
int contador;
int entrada;
int salida;
int posFrase;
int posLlave;
int producidos;
int consumidos;
FILE *file;
FILE *cesar;
char *llave;
int tamBuffer;
static char *archivo;
void... | 0 |
#include <pthread.h>
int NO_READERS;
int NO_WRITERS;
int NO_READERS_READING = 0;
int NO_WRITERS_WRITING = 0;
bool VERBOSE;
pthread_mutex_t resourceMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t tryResourceMutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t readerMutex = PTHREAD_MUTEX_INITIALIZ... | 1 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_t tidP[20],tidC[20];
sem_t full,empty;
int counter;
int buffer[10];
void initialize()
{
pthread_mutex_init(&mutex,0);
sem_init(&full,1,0);
sem_init(&empty,1,10);
counter=0;
}
void write(int item)
{
buffer[counter++]=item;
}
int read()
{
... | 0 |
#include <pthread.h>
extern int function_status;
extern pthread_mutex_t mut;
extern FILE* fp_small;
extern FILE* fp_big;
extern int gameLdStatus;
void initAction()
{
gameLdStatus = -1;
initPeripheral();
}
void oledOutput(int num, int status)
{
clearImage();
switch(status)
{
case -1:
br... | 1 |
#include <pthread.h>
static pthread_mutex_t l_memleak_lock = PTHREAD_MUTEX_INITIALIZER;
struct mem_leak{
unsigned int size;
void *mem;
char file[NAME_MAX];
int line;
struct mem_leak *next;
};
struct mem_leak *mem_head = 0;
static unsigned int mem_total = 0;
void *mem_leak_al... | 0 |
#include <pthread.h>
unsigned int nR = 0;
unsigned int nW = 0;
unsigned int rCnt = 0;
unsigned int wCnt = 0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t okR = PTHREAD_COND_INITIALIZER;
pthread_cond_t okW = PTHREAD_COND_INITIALIZER;
void readerIn(){
pthread_mutex_lock... | 1 |
#include <pthread.h>
int M, N, count = 1;
static pthread_mutex_t *mutex;
pthread_t *thread = 0;
int *thread_ID = 0;
void *thread_func(void *arg);
int main(int argc, char const *argv[]){
if (argc != 3){
printf("Usage: ./ex6 M N, M threads, N counting!\\n");
return 0;
}
printf("Mutex pro... | 0 |
#include <pthread.h>
int quitflag;
sigset_t mask;
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
void *thr_fn(void *arg) {
int err, signo;
pthread_t tid = pthread_self();
for( ; ; ) {
err = sigwait(&mask, &signo);
if(err != 0)
... | 1 |
#include <pthread.h>
void display_statistics(){
struct timeval current_time;
gettimeofday(¤t_time, 0);
float temp = calculate_time_difference(current_time,emulation_start_time);
printf("%012.3fms: emulation ends\\n",temp);
pthread_mutex_lock(&mutex);
printf("Total Q1... | 0 |
#include <pthread.h>
char rxFrame[MAXRXFRAME];
char logBuffer[MAXLOGBUFFER];
ssize_t readline(int fd, void *vptr, size_t maxlen);
void decodeRxFrame(void);
void resyncFrame(void);
void ackFrame(void);
void *rx_thService(void *arg)
{
int n;
bzero(logBuffer, sizeof(logBuffer));
sprintf(logBuf... | 1 |
#include <pthread.h>
struct servent *getservbyport(int port, const char *proto)
{
char *buf = _serv_buf();
if (!buf)
return 0;
return getservbyport_r(port, proto, (struct servent *) buf,
buf + sizeof(struct servent), SERV_BUFSIZE);
}
struct servent *getservbyport_r(int port, const ... | 0 |
#include <pthread.h>
char y, x;
}POSICAO;
char fim, humano,num;
int tempo;
}JOGADOR;
int maxY, maxX;
POSICAO ele[4]={ {3,10},{15,15},{12,40},{19,45}};
pthread_mutex_t trinco;
void *move_jogador(void *dados){
JOGADOR *j;
POSICAO d;
int ch;
j=(JOGADOR *) dados;
do{
if (!j->humano){
ch=rand... | 1 |
#include <pthread.h>
pthread_mutex_t globalMutex[2];
pthread_cond_t globalCondVar[2];
static void *threadFunc1(void *args)
{
assert(args == 0);
pthread_mutex_lock(&globalMutex[0]);
pthread_cond_wait(&globalCondVar[0], &globalMutex[0]);
printf("X modified by threadFunc 1\\n");
pth... | 0 |
#include <pthread.h>
int sockfd;
int recvCounter[256];
float neighbourRR[256];
char recvRouter[MAX_PACKET_LEN];
int recvLen;
pthread_mutex_t recv_mutex;
pthread_t p_id;
pthread_attr_t p_attr;
void cul_linkQuality();
void recv_init(){
printf("recv_init\\n");
if( (sockfd = socket(AF_INET, SO... | 1 |
#include <pthread.h>
void
ports_resume_class_rpcs (struct port_class *class)
{
pthread_mutex_lock (&_ports_lock);
assert_backtrace (class->flags & PORT_CLASS_INHIBITED);
class->flags &= ~PORT_CLASS_INHIBITED;
if (class->flags & PORT_CLASS_BLOCKED)
{
class->flags &= ~PORT_CLASS_BL... | 0 |
#include <pthread.h>
int A[] = {1, 7, 9, -33, 1, 4, 11, 0, 891, 3};
int FOUND = 0;
int COUNT = 0;
pthread_mutex_t lock;
void *partition(void *p)
{
int i;
long tid = (long) p;
int numCells = 10 / 10;
int remainingCells = 10 % 10;
int startCell = numCells * tid;
int e... | 1 |
#include <pthread.h>
struct prodcons {
int buffer[8];
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... | 0 |
#include <pthread.h>
void
ports_resume_port_rpcs (void *portstruct)
{
struct port_info *pi = portstruct;
pthread_mutex_lock (&_ports_lock);
assert_backtrace (pi->flags & PORT_INHIBITED);
pi->flags &= ~PORT_INHIBITED;
if (pi->flags & PORT_BLOCKED)
{
pi->flags &= ~PORT_BLOCKED;... | 1 |
#include <pthread.h>
void print_error(int error, char* message){
puts(message);
puts(strerror(error));
}
void print_error_exit(int error, char* message){
puts(message);
puts(strerror(error));
exit(1);
}
void * search_file(void * text_to_find);
int file_desc;
pthread_t *thread... | 0 |
#include <pthread.h>
pthread_cond_t mycond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
{
int _data;
struct node* _next;
}node_t,*node_p,**node_pp;
node_p CreatNode(node_pp list, int data)
{
assert(list);
node_p node = (node_p)malloc(sizeof(node... | 1 |
#include <pthread.h>
int scapremedy_exec(const char * dir, const char *remediation_file)
{
pid_t pid;
pid = fork();
if ( pid == 0 )
{
int fd = open("/dev/null", O_RDONLY);
int fd2;
int i;
struct rscap_hash * hash;
const char * cmd;
const char * argv_list[1024];
char ... | 0 |
#include <pthread.h>
int state[5];
int chopstick[5];
pthread_mutex_t mutex;
pthread_cond_t con_var;
void *at_table(void* i);
void test();
int main(int argc, const char * argv[]) {
for (int i = 0; i < 5; ++i) {
chopstick[i] = 1;
state[i] = 1;
}
srand(time(0));... | 1 |
#include <pthread.h>
void
send_req(int fd, struct qstat *tt)
{
volatile uint64_t a;
char ver[64];
struct iovec iov[6] = { {.iov_base = "GET ", .iov_len = 4},
{.iov_base = gp, .iov_len = gl},
{.iov_base = ver, .iov_len = 0},
{.iov_base = " HTTP/1.1\\r\\nHost: ", .iov_len = 17},
{.i... | 0 |
#include <pthread.h>
uint64_t nb;
FILE * file;
char str[60];
pthread_t thread0;
pthread_t thread1;
pthread_mutex_t lock;
pthread_mutex_t lockScreen;
const int MAX_FACTORS=64;
void print_prime_factors(uint64_t n);
int get_prime_factors(uint64_t n,uint64_t* dest);
void* thread_prime_facto... | 1 |
#include <pthread.h>
void *thread_function(void *arg);
pthread_mutex_t work_mutex;
char work_area[1024];
int time_to_exit = 0;
int main()
{
int res;
pthread_t a_thread;
void *thread_result;
res = pthread_mutex_init(&work_mutex, 0);
if (res != 0)
{
perror("Mutex i... | 0 |
#include <pthread.h>
static pthread_barrier_t barrier;
static pthread_t *writers, *readers;
static pthread_mutex_t lock;
void *reader(void *arg)
{
unsigned nreads = *(unsigned *)arg, i;
int p;
volatile int tmp = 0;
pthread_barrier_wait(&barrier);
ct_start_clock();
for (i = 0; i < nrea... | 1 |
#include <pthread.h>
struct msg {
struct msg *m_next;
};
struct msg *workq;
pthread_cond_t qready = PTHREAD_COND_INITIALIZER;
pthread_mutex_t qlock = PTHREAD_MUTEX_INITIALIZER;
void process_msg() {
struct msg *mp;
for (;;) {
pthread_mutex_lock(&qlock);
while (workq == 0)
... | 0 |
#include <pthread.h>
void welcome(char* nickname, char* username, char* hostname, int socket) {
char* msg = (char*)malloc(MAX_MSG_LEN+1);
msg[0] = '\\0';
sprintf(msg,":%s 001 %s :Welcome to the Internet Relay Network %s!%s@%s\\r\\n",
serverHost,nickname,nickname,username,hostname)... | 1 |
#include <pthread.h>
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t condition = PTHREAD_COND_INITIALIZER;
static void *
my_condition_thread (void * arg)
{
pthread_mutex_lock (&mutex);
printf (" thread: enter CS\\n");
sleep (4);... | 0 |
#include <pthread.h>
int first,second;
}two_ints_t;
void* server(void *arg){
int i = 0;
int r = 15;
while(1){
printf("%d\\n",i);
i ++;
if(i == 10)
{
pthread_exit((void*)&r);
}
}
}
pthread_t start_servers(){
pthread_t thread;
pthread_attr_t attr;
pthread_attr_init(&attr);
... | 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;
pthread_mutex_unlock(&my);
a =... | 0 |
#include <pthread.h>
extern char** environ;
static pthread_key_t key;
static pthread_once_t once_init = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void thread_init(void) { pthread_key_create(&key, free); }
char* getenv(const char* name)
{
pthread_onc... | 1 |
#include <pthread.h>
pthread_t thread1, thread2;
static pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
void *workOne(void *arg) {
pthread_mutex_lock(&lock1);
usleep(1000);
pthread_mutex_unlock(&lock1);
pthread_mutex... | 0 |
#include <pthread.h>
static struct malloc_infos arena;
static int __malloc_initialized = 0;
static void
lock(void)
{
if (unlikely(!__malloc_initialized))
return ;
pthread_mutex_lock(&arena.mutex);
}
static void
unlock(void)
{
if (unlikely(!__malloc_initialized))
return ;
... | 1 |
#include <pthread.h>
struct mode_extra_status
{
int output_pipe_fd;
pthread_mutex_t mutex;
union switch_data answer;
long long rest_time[SWITCH_BUTTON_NUM + 1];
int score;
pthread_t background_worker;
bool terminated;
};
static void *background_worker_main (void *arg);
struct... | 0 |
#include <pthread.h>
static struct netlink_listener *nl;
static int local_socket;
static pthread_mutex_t init_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t start_lock = PTHREAD_MUTEX_INITIALIZER;
static uint32_t init_count;
static uint32_t start_count;
static int start(void) {
... | 1 |
#include <pthread.h>
pthread_mutex_t vt_lcd_mutex = PTHREAD_MUTEX_INITIALIZER;
void VTinit(void)
{
VTinitialize_ports();
VTinitLCD();
}
void VTinitialize_ports() {
XGpio_mSetDataDirection(XPAR_LCD_BASEADDR, 2, 0x0);
XGpio_mSetDataDirection(XPAR_LCD_BASEADDR, 1, 0xffffffff);
}
... | 0 |
#include <pthread.h>
int insideCircleCount = 0;
int roundsPerThread = 0;
int threadNum = 0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *MonteCarlo(){
int pointsInCircleFromThread = 0;
unsigned int rand_state = rand();
int i;
for(i = 0; i < roundsPerThread; i++){
double x ... | 1 |
#include <pthread.h>
int MAX_NUMBER = 65535;
int max_m_operations = 200;
int thread_count = 8;
int initial_length = 10;
int seed =18;
double member_fraction = 0.80;
double insert_fraction = 0.10;
double delete_fraction = 0.10;
struct node** head_node;
pthread_mutex_t list_mutex;
int max_member... | 0 |
#include <pthread.h>
struct message_queue {
struct message_queue* next;
int count;
} * tasks;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condition = PTHREAD_COND_INITIALIZER;
struct message_queue* process_message(void* thread_num)
{
pthread_mutex_lock(&mutex);
... | 1 |
#include <pthread.h>extern int __VERIFIER_nondet_int(void);
extern void __VERIFIER_error() ;
int element[(20)];
int head;
int tail;
int amount;
} QType;
pthread_mutex_t m;
int __VERIFIER_nondet_int();
int stored_elements[(20)];
_Bool enqueue_flag, dequeue_flag;
QType queue;
void ... | 0 |
#include <pthread.h>
int n_buckets;
int contador = 0;
pthread_mutex_t lock;
int *values;
int tamanho;
}bucket;
void bubble_sort(int *v, int tam){
int i,j,temp,trocou;
for(j=0; j<tam-1; j++){
trocou = 0;
for(i = 0; i < tam -1; i++){
if(v[i+1] < v[i]){
temp = v[i];
... | 1 |
#include <pthread.h>
void
netfs_release_peropen (struct peropen *po)
{
pthread_mutex_lock (&po->np->lock);
if (--po->refcnt)
pthread_mutex_unlock (&po->np->lock);
else
{
if (po->root_parent)
mach_port_deallocate (mach_task_self (), po->root_parent);
if (po->shadow_root ... | 0 |
#include <pthread.h>
int count = 5;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void *decrement(void *arg);
void *increment(void *arg);
int main(int argc, char const *argv[])
{
int i1 = 1;
int i2 = 1;
pthread_t tid1;
pthread_t tid2;
pth... | 1 |
#include <pthread.h>
int mediafirefs_removexattr(const char *path, const char *list)
{
printf("FUNCTION: removexattr. path: %s\\n", path);
(void)path;
(void)list;
struct mediafirefs_context_private *ctx;
ctx = fuse_get_context()->private_data;
pthread_mutex_lock(&(c... | 0 |
#include <pthread.h>
void * thread_section(void* i);
int check_prime(int i);
void kill_threads();
pthread_t threads[5];
pthread_mutex_t lock;
int found = 0;
int main() {
int i, status;
if (pthread_mutex_init(&lock, 0) != 0) {
printf("\\n mutex init failed\\n");
exit(1);
}
sr... | 1 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t vez = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t lotou = PTHREAD_COND_INITIALIZER;
int contador = 0;
int contador_servidores = 0;
int contador_estagiarios = 0;
void* servidor(void * a){
int i = *((int *) ... | 0 |
#include <pthread.h>
pthread_mutex_t chopstick[6] ;
void *eat_think(void *arg)
{
char phi = *(char *)arg;
int left,right;
switch (phi){
case 'A':
left = 5;
right = 1;
break;
case 'B':
left = 1;
right = 2;
break;
case 'C':
left = 2;
right = 3;
break;
case 'D':
... | 1 |
#include <pthread.h>
uint32_t Timer_timeouts[NB_SOFT_TIMERS];
uint8_t Timer_wraps[NB_SOFT_TIMERS];
uint32_t Timer_prev;
pthread_mutex_t Timer_mut;
uint32_t Timer_millis()
{
struct timespec current;
int res;
uint32_t millis;
res = clock_gettime(CLOCK_REALTIME, ¤t);
if (res != 0) ... | 0 |
#include <pthread.h>
{
int k,i;
}param;
int graph[100][100];
int n;
pthread_mutex_t mutex;
void *iterate (void *t)
{
pthread_mutex_lock(&mutex);
struct param *parameters=t;
int k=parameters->k;
int i=parameters->i;
int j=0;
for(j=0;j<n;j++)
{
if(graph[i][k]+graph[k][j]<graph[i][j])
{... | 1 |
#include <pthread.h>
void msg_mutex_init(pthread_mutex_t *mutex)
{
pthread_mutexattr_t mutexattr;
pthread_mutexattr_init(&mutexattr);
pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED);
pthread_mutex_init(mutex, &mutexattr);
}
void msg_cond_init(pthr... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.