text stringlengths 192 6.24k | label int64 0 1 |
|---|---|
#include <pthread.h>
extern int __setlogin(const char* name);
extern pthread_mutex_t __logname_mutex;
extern char *__logname;
int setlogin(const char* name)
{
pthread_mutex_lock(&__logname_mutex);
int res = __setlogin(name);
if (res == 0 && __logname != 0) {
__logname[0] = 0;
}
pthread_... | 1 |
#include <pthread.h>
extern char server_ip[];
extern int server_port;
extern struct tabella_memoria *memory;
extern struct lista *lista_blocchi;
struct tabella_memoria *popolaMemoria(char *file) {
printf("* Lettura dati dal file %s, inizializzazione memoria... ",file);
fflush(stdout);
FILE *fp... | 0 |
#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... | 1 |
#include <pthread.h>
static struct mod_object *modules;
static pthread_mutex_t mtx_mod;
void
mod_init(void)
{
pthread_mutex_init(&mtx_mod, 0);
}
int
mod_load(char *mod)
{
struct mod_object *mhand, *mlist;
void (*module_init)(struct mod_object *);
int (**func_mod_load)(char *... | 0 |
#include <pthread.h>
int pthread_barrier_init(pthread_barrier_t *barrier,
const pthread_barrierattr_t *attr, unsigned int count)
{
if (unlikely(!barrier) || unlikely(count == 0)) {
errno = EINVAL;
return -1;
}
if (attr && (*attr != PTHREAD_PROCESS_PRIVATE)) {
errno = EINVAL;
retur... | 1 |
#include <pthread.h>
float** main_plate;
float** main_prev_plate;
char** main_locked_cells;
pthread_barrier_t barrier_first;
pthread_barrier_t barrier_second;
pthread_mutex_t critical_begin_end;
pthread_mutex_t runnable;
int nthreads;
int begin;
int end;
} arg_plate_t;
double when() {
struct... | 0 |
#include <pthread.h>
void *filosofo (void *id);
void pegaGarfo (int, int, char *);
void devolveGarfo (int, int, char *);
void pensar(int);
void comer(int);
int comidaNaMesa ();
int numero_filosofos;
pthread_mutex_t *garfo;
pthread_t *filo;
pthread_mutex_t comidaBloqueada;
int sleep_seco... | 1 |
#include <pthread.h>
void *pool_manager(void *attr);
int WORKERS = 10;
pthread_mutex_t m;
pthread_cond_t cond;
int S[100];
int TOP = -1;
void push(int data){
if(TOP==99) return;
S[++TOP] = data;
}
int pop(){
if(TOP==-1) return -1;
return S[TOP--];
}
void init_pool(){
int ... | 0 |
#include <pthread.h>
extern pthread_mutex_t mtx;
extern int level;
void* bus_led()
{
int wdata ,rdata,temp ;
int fd;
int num;
fd = open("/dev/cnled", O_RDWR);
if(fd < 0) {
perror("driver (//dev//cnled) open errir.\\n");
exit(0);
}
while(level!=6) {
pthread_mutex_lock(&mtx);
... | 1 |
#include <pthread.h>
void *ticketsell1(void *);
void *ticketsell2(void *);
int tickets = 20;
pthread_mutex_t mutex;
int main() {
pthread_t id1,id2;
pthread_mutex_init(&mutex,0);
int error;
error = pthread_create(&id1,0,ticketsell1,0);
if(error != 0){
printf("pthread is... | 0 |
#include <pthread.h>
int arr[10];
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
static pthread_barrier_t barrier;
static int avail = 0;
static void *producer(void *arg)
{
sleep(1);
printf("\\n%s: Started producing..\\n", _... | 1 |
#include <pthread.h>
pthread_mutex_t mutex;
void* imprimir(void*);
int j=0;
int main(void) {
pthread_mutex_init(&mutex,0);
pthread_t hilo[30];
int i;
for (i=0;i<30;i++) {
pthread_create(&hilo[i],0,&imprimir,&i);
}
for (i=0;i<30;i++) {
pthread_join(hilo[i],0);
}
pthread_mutex_destr... | 0 |
#include <pthread.h>
pthread_t workerid[3];
pthread_mutex_t lock;
pthread_cond_t read;
pthread_cond_t writeStd;
pthread_cond_t writeFile;
char * line[100];
void * readInput(void *arg);
void * writeOutput(void *arg);
void * writeToFile(void *arg);
int main(int argc, char *argv[]){
char*... | 1 |
#include <pthread.h>
int numThreads;
double a, b, h;
int n, local_n;
pthread_mutex_t mutex;
double total;
double funcion(double x) {
double funcionEvaluar;
funcionEvaluar = x*x;
return funcionEvaluar;
}
double trapezoidalFun(double local_a, double local_b, int local_n, double h) {
... | 0 |
#include <pthread.h>
int NumProcs;
int **grid[2];
int timesteps, xdim, ydim;
pthread_mutex_t SyncLock;
pthread_cond_t SyncCV;
int SyncCount;
pthread_mutex_t ThreadLock;
void Barrier()
{
int ret;
pthread_mutex_lock(&SyncLock);
SyncCount++;
if(SyncCount == NumProcs) {
ret = pthread_cond_broa... | 1 |
#include <pthread.h>
int i, k;
pthread_mutex_t msg_mutex = PTHREAD_MUTEX_INITIALIZER;
int log_count = 0;
void
send_response (pthread_t tid)
{
unsigned int k = (int) tid;
int j;
unsigned int flight_number = k % 10000;
if (k % 5 == 1)
{
printf
("FLIGHT NO. %u \\n\\t PERMISS... | 0 |
#include <pthread.h>
int threadNumber;
int lBound;
int uBound;
} bounds;
void *prime(void *number);
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int counter = 0;
int main(int argc, char **argv)
{
int rc1;
pthread_t *currThread;
bounds * cliBounds;
int currentNu... | 1 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_cond_t cond;
enum Statu{ Main=0,Son=1,ThreadNum };
enum Statu Running=Son;
const int loop_times=50;
void* son_thread(void * arg){
pthread_mutex_lock(&mutex);
for(int ci=0;ci<loop_times;){
if(Running==Son){
f... | 0 |
#include <pthread.h>
size_t start;
size_t end;
uint16_t * data;
int * hist;
pthread_mutex_t lock;
} Worker;
void increment_bucket(Worker * t_work, int bucket) {
pthread_mutex_lock(&t_work->lock);
t_work->hist[bucket]++;
pthread_mutex_unlock(&t_work->lock);
}
void * fill_buckets(void * ... | 1 |
#include <pthread.h>
static pthread_mutex_t my_mutex;
static int tab[5];
void *read_tab_process (void * arg)
{
int i;
pthread_mutex_lock (&my_mutex);
for (i = 0 ; i != 5 ; i++)
printf ("read_process, tab[%d] vaut %d\\n", i, tab[i]);
pthread_mutex_unlock (&my_mutex);
pthread_exit (0... | 0 |
#include <pthread.h>
void* thread1( void* pParam );
void* thread2( void* pParam );
int count1 = 0;
int count2 = 0;
pthread_mutex_t mutex;
pthread_t Thread_create( void* (*start_routine)( void* ) )
{
pthread_t tid;
pthread_create( &tid, 0, start_routine, 0 );
return tid;
}
void Thread_wai... | 1 |
#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);
}
void parent(void)
{
printf("parent unlocking locks...\\n");
pthread_mutex_unlock(&lock1);... | 0 |
#include <pthread.h>
void try_reconnect(struct asd_pool* pool, int sockfd) {
int fdi;
for(fdi = 0; fdi < pool->num_connections; fdi++) {
if(pool->connections[fdi].fd == sockfd) {
close(pool->connections[fdi].fd);
pool->connections[fdi].fd = connect_to_server(pool->host... | 1 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_cond_t cond34;
volatile int t34 = 0;
void *T1 (void * tid) {
printf("tudo bem?\\n");
pthread_mutex_lock(&mutex);
t34++;
if(t34 == 2) { pthread_cond_broadcast(&cond34); }
pthread_mutex_unlock(&mutex);
pthread_exit(0);
}
void *T2 (... | 0 |
#include <pthread.h>
long globalCntr;
long allUpdates;
int doSomeMath(int inVal){
double d = atan2((double) inVal,0.1);
d=log(d);
int q=(int)ceil(d);
return 1;
}
int floatOperations(struct evaluatorStat *gg){
float f1 = .4444;
float f2 = .621678;
for(int i = 0; i<gg->NrOfWork ; i+... | 1 |
#include <pthread.h>
longArchFix sum, numbersPerProcess;
pthread_mutex_t sum_mutex;
static void usage(char *prog_name, char *msg)
{
if (msg != 0)
fputs(msg, stderr);
fprintf(stderr, "Usage: %s [options]\\n", prog_name);
fprintf(stderr, "Options are:\\n");
fprintf(stderr, "\\... | 0 |
#include <pthread.h>
pthread_mutex_t fork_mutex[3];
pthread_mutex_t eat_mutex;
main()
{
int i;
pthread_t diner_thread[3];
int dn[3];
void *diner();
pthread_mutex_init(&eat_mutex, 0);
for (i=0;i<3;i++)
pthread_mutex_init(&fork_mutex[i], 0);
for (i=0;i<3;i++){
dn[i] = i;
... | 1 |
#include <pthread.h>
long countin = 0;
long thread_iteration_number = 0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
void* worker(){
long i;
long countin_t = 0;
unsigned int globalSeed = rand();
for (i = 0; i < thread_iteration_number; i++){
double x = rand_r(&globalSeed) / (... | 0 |
#include <pthread.h>
static int buffer[8];
static int n = 0;
static pthread_mutex_t lock;
static pthread_mutex_t mutex1;
static pthread_mutex_t mutex2;
pthread_cond_t filaCheia = PTHREAD_COND_INITIALIZER;
pthread_cond_t filaVazia = PTHREAD_COND_INITIALIZER;
void produtor(void)
{
int i = 0;
wh... | 1 |
#include <pthread.h>
void *producer ();
void *consumer ();
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int *pipeClean;
int num_pairs, num_transfers;
struct thread_data {
char pipeName[20];
int pairNum;
};
int main(int argc, char **argv) {
int i, t1, t2, num_threads;
char namebuf[20],... | 0 |
#include <pthread.h>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;
int init(QType *q)
{
q->head=0;
q->tail=... | 1 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
int source = 0;
void *t1_handler(void *arg)
{
int i;
int ret;
printf("1\\n");
for(i = 0; i < 1000000; i++){
pthread_mutex_lock(&mutex1);
source++;
again:
ret... | 0 |
#include <pthread.h>
void *constructor_refresh_thread(void *e)
{
(void)e;
while (1)
{
sgt_constructor()->select = !sgt_constructor()->select;
pthread_mutex_lock(&sgt_constructor()->mutex_preview);
constructor_calcul();
pthread_mutex_unlock(&sgt_constructor()->mutex_preview);
usleep(1... | 1 |
#include <pthread.h>
int works_count = 0;
pthread_mutex_t job_queue_mutex = PTHREAD_MUTEX_INITIALIZER;
sem_t job_queue_count;
void task(const int* value){
printf(" [work] | now working on %d.\\n", *value);
}
struct job {
struct job* next;
void (*func)(const int*);
};
struct job* job_... | 0 |
#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(void)
{
struct msg *mp;
for (;;) {
pthread_mutex_lock(&qlock);
while (workq == 0)
... | 1 |
#include <pthread.h>
void *philosopher (void *id);
void grab_chopstick (int,
int,
char *);
void down_chopsticks (int,
int);
int food_on_table ();
pthread_mutex_t chopstick[5];
pthread_... | 0 |
#include <pthread.h>
static time_t time_orig;
static time_t time_interval;
static int bool_black = 0;
static pthread_mutex_t mutex_screen = PTHREAD_MUTEX_INITIALIZER;
static char screen_light_buf[4];
static int screen_set_time(time_t time)
{
return_val_if_fail(time > 0, -1);
miui_... | 1 |
#include <pthread.h>
pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
void prepare (void)
{
printf ("prepareing locks...\\n");
pthread_mutex_lock (&lock1);
pthread_mutex_lock (&lock2);
}
void parent (void)
{
printf ("parent unlocking locks... | 0 |
#include <pthread.h>
int ProcCurr[3][3];
int temp[3][3];
int Available[10];
int Max[3][3] = { {10,10,10},{10,10,10},{10,10,10} };
int Allocation[3][3] = { {1,2,3},{3,2,1},{1,1,1} };
int Need[3][3];
int counti = 0;
int countj = 0;
int threadsi = 3;
int threadsj = 3;
void *inc_count(void *r);
vo... | 1 |
#include <pthread.h>
struct range {
int begin;
int end;
};
int *array = 0;
int N = 0;
pthread_mutex_t queue_mutex;
pthread_cond_t queue_cond;
int completed = 0;
pthread_mutex_t completed_mutex;
bool is_completed() {
pthread_mutex_lock(&completed_mutex);
bool res = (completed == N);
... | 0 |
#include <pthread.h>
long int sum;
pthread_mutex_t m;
void *runner(void * param);
main(int argc, char *argv[])
{
int num_threads, i;
pthread_t tid[10];
pthread_attr_t attr;
if (argc != 2) {
fprintf(stderr, "usage: a.out <integer value>\\n");
exit(-1);
}
if (atoi(argv[1]) ... | 1 |
#include <pthread.h>
struct bbq_node
{
struct bbq_node *next;
int value;
};
struct bbq_node *head=0;
struct bbq_node *tail=0;
struct bbq_node *p_ptr=0;
struct bbq_node *c_ptr=0;
unsigned int N, P, C, X, Dequeue, Ptime, con_time;
sem_t emptyCount;
sem_t fullCount;
int bbq_counter ... | 0 |
#include <pthread.h>
void *vestiario();
void *piscina();
void *limpeza();
int num_nadadores;
int contBanho = 0;
int segundoBanho = 0;
pthread_mutex_t mutex1;
pthread_mutex_t mutex2;
sem_t chuveiros;
sem_t raias;
bool raia1 = 1;
bool raia2 = 1;
bool raia3 = 1;
bool raia4 = 1;
bool raia5 = 1... | 1 |
#include <pthread.h>
{
pthread_cond_t biglietteria_libera;
pthread_cond_t partenza_gruppo;
pthread_cond_t finito_servire_utente;
pthread_cond_t gruppo_libero;
pthread_mutex_t mut;
int n_in_gruppo;
int n_in_coda_biglietteria;
int n_gruppi_partiti;
bool biglietteria_occupata;
}monitor;... | 0 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_cond_t cond;
void *traveler_arrive( void *p )
{
char *name = (char *)p;
printf( "Traveler %s needs a taxi now.\\n",name );
pthread_mutex_lock( &mutex );
pthread_cond_wait( &cond,&mutex );
pthread_mutex_unlock( &mutex )... | 1 |
#include <pthread.h>
int isp_app_msg_queue_create(unsigned int count, unsigned int *queue_handle)
{
struct isp_app_msg_cxt *msg_cxt;
if (0 == count) {
return -ISP_APP_MSG_PARAM_ERR;
}
msg_cxt = (struct isp_app_msg_cxt*)malloc(sizeof(struct isp_app_msg_cxt));
if (0 == msg_cxt) {
return -... | 0 |
#include <pthread.h>
struct msg {
struct msg *m_next;
char *data;
};
struct msg *workq;
pthread_cond_t qready = PTHREAD_COND_INITIALIZER;
pthread_mutex_t qlock = PTHREAD_MUTEX_INITIALIZER;
void
process_msg(int thread)
{
struct msg *mp;
for (;;) {
pthread_mutex_lock(&ql... | 1 |
#include <pthread.h>
pthread_mutex_t gSharedValueLock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t gReadCondition = PTHREAD_COND_INITIALIZER;
pthread_cond_t gWriteCondition = PTHREAD_COND_INITIALIZER;
unsigned int gSharedValue = 0;
int gReaderCount = 0;
int gWaitingReaderCount = 0;
void *reader(v... | 0 |
#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;
static void *thr_primer(void *p);
int main()
{
int i,j,mark;
int err;
pthread_t tid[4];
for(i = 0; i < 4 ; i++)
{
err = pthr... | 1 |
#include <pthread.h>
int counter = 0;
pthread_mutex_t counter_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t threshold_condv = PTHREAD_COND_INITIALIZER;
void *inc_counter(void *thread_id)
{
long th_id = (long) thread_id;
for (int ii = 0; ii < 10; ii++) {
pthread_mutex_lock... | 0 |
#include <pthread.h>
static char const *short_usage =
("Usage: egytian_cotton [-fhv] [-n num_threads] [-s bytes]\\n");
static char const *flags_usage =
(" -f expect thread creation to fail for given\\n"
" thread creation parameters\\n"
" -h longer help\\n"... | 1 |
#include <pthread.h>
int buffer[5];
int count = 0;
int front = -1;
int rear = 0;
pthread_mutex_t lock;
pthread_cond_t nonFull;
pthread_cond_t nonEmpty;
void *producerWork(void *);
void *consumerWork(void *);
void bufferAdd(int);
int bufferRemove();
int main(int argc, char * argv[]) ... | 0 |
#include <pthread.h>
static uint64_t global_int;
static pthread_mutex_t lock;
void bounds_error()
{
printf("Argument out of bounds:\\n"
"t must be between %lu and %lu,\\n"
"n must be between %lu and %lu.\\n",
1l, 16l, 1l, 1000000000l);
exit(1);
}
void *... | 1 |
#include <pthread.h>
pthread_t tid[4];
pthread_mutex_t mutex;
int *array;
int length = 1000000000;
int count = 0;
int double_count = 0;
int t = 4;
int max_threads = 0;
struct padded_int{
int value;
char padding[60];
}private_count[4];
void *count3s_thread(void *arg)
{
clock_t startTim... | 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(str... | 1 |
#include <pthread.h>
{
int thread_done ;
int rs232Ctrl ;
} Thdata;
void print_signal_status(int) ;
int getch() ;
pthread_mutex_t mutex_rs232_receiver = PTHREAD_MUTEX_INITIALIZER ;
int getch(void)
{
int c=0;
struct termios org_opts, new_opts;
int res=0;
... | 0 |
#include <pthread.h>
void psm_init(struct positrack_shared_memory* psm)
{
int i;
psm->numframes=POSITRACKSHARENUMFRAMES;
for(i = 0 ; i < psm->numframes; i++)
{
psm->id[i]=0;
psm->frame_no[i]=0;
psm->ts[i].tv_sec=0;
psm->ts[i].tv_nsec=0;
psm->x[i]=-1;
... | 1 |
#include <pthread.h>
pthread_mutex_t saldo_mutex;
unsigned int saldo;
void *PrintHello(void *threadid)
{
long tid;
unsigned misaldo;
tid = (long)threadid;
pthread_mutex_lock(&saldo_mutex);
misaldo=saldo;
misaldo+=1;
if(tid%2==0)sleep(1);
saldo=misaldo;
pthread_mutex_u... | 0 |
#include <pthread.h>
int count = 0;
pthread_mutex_t count_mutex;
pthread_cond_t count_threshold_cv;
void *inc_count(void *idp)
{
int j,i;
double result=0.0;
long my_id = (long)idp;
for (i=0; i < 10; i++) {
pthread_mutex_lock(&count_mutex);
count++;
if (count ==... | 1 |
#include <pthread.h>
uint64_t i;
uint64_t j;
} walkargs;
uint64_t max = 100;
int numthreads=0;
int maxthreads=4;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_t *tid;
unsigned char *grid;
void *walkovergrid(void *args){
... | 0 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_t thr1, thr2, thr3;
pthread_attr_t attr1, attr2, attr3;
void * fonction_2(void * unused)
{
int i, j;
fprintf(stderr, " T2 demarre\\n");
fprintf(stderr, " T2 travaille...\\n");
for (i = 0; i < 100000; i ++)
for (j = 0; j < 10000; j +... | 1 |
#include <pthread.h>
struct info_sclad {
int sclad[5];
int *cl_need;
int count_cl;
int *index;
};
pthread_mutex_t lock1;
pthread_mutex_t lock2;
pthread_mutex_t lock3;
pthread_mutex_t lock4;
pthread_mutex_t lock5;
pthread_mutex_t cl;
void zag_sig(int signo)
{
printf("end work... | 0 |
#include <pthread.h>
pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cnd = PTHREAD_COND_INITIALIZER;
struct global_data{
char task;
const int count;
};
void * task_a(void * ctx)
{
struct global_data *d = ctx;
int i;
printf("started task_a\\n");
for(i=... | 1 |
#include <pthread.h>
static pthread_key_t key;
static pthread_once_t init_done = PTHREAD_ONCE_INIT;
pthread_mutex_t env_mutex = PTHREAD_MUTEX_INITIALIZER;
extern char **environ;
static void
thread_init(void)
{
pthread_key_create(&key, free);
}
char *
getenv(const char *name)
{
int i, len;
... | 0 |
#include <pthread.h>
pthread_mutex_t mutex;
pthread_t threads[8];
uint8_t Image[(1024*4)][(1024*4)];
int id;
double Re1, Im1, Re2, Im2;
double threshold;
int xo, yo;
int width, height;
int maxiters;
} Job;
Job jobs[(((1024*4))/256 * ((1024*4))/256)];
int free_job_idx = 0;
int pr... | 1 |
#include <pthread.h>
void *playAudioThread(void *arg) {
int status;
appLog(LOG_DEBUG, "inside playAudioThread..........");
char *filename = arg;
char *FilePath;
FilePath = malloc(FILE_PATH_LEN_MAX);
if (!FilePath) {
appLog(LOG_DEBUG, "allocated memory failed, thread %d exited",
(int)... | 0 |
#include <pthread.h>
pthread_cond_t is_waiting[10];
pthread_cond_t is_haircutting = PTHREAD_COND_INITIALIZER;
pthread_mutex_t semaphore = PTHREAD_MUTEX_INITIALIZER;
pthread_t t1, t2[10];
int args[10];
int next = 0;
int last = 0;
int waiting_customers_qty;
int seats[8];
int customer_status[10];... | 1 |
#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... | 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);
o... | 1 |
#include <pthread.h>
struct User_list* list_init()
{
struct User_list* list = malloc( sizeof( struct User_list ) );
list->head = 0;
pthread_mutex_init( &( list->mutex ), 0 );
return list;
}
void list_free( struct User_list* list )
{
if( list == 0 )
{
return;
... | 0 |
#include <pthread.h>
pthread_mutex_t chop_mutex[5];
void *doit(void *vptr)
{
int *i,a,b;
i = vptr;
while(1)
{
pthread_mutex_lock(&chop_mutex[(*i + 4) % 5]);
printf("Philosopher %c fetches chopstick %d\\n", *i + 'A',(*i + 4) % 5);
if (!pthread_mutex_trylock(&chop_mutex[*i]))
{
print... | 1 |
#include <pthread.h>
pthread_t thread[2];
pthread_mutex_t mut;
int share_resource = 0, i;
void *thread1()
{
printf("thread1 : I'm thread 1\\n");
for (i = 0; i < 5; i++) {
printf("thread1 : share_resource = %d\\n", share_resource);
pthread_mutex_lock(&mut);
share_resource++;
pthre... | 0 |
#include <pthread.h>
struct thread_data
{
int thread_id;
int offset;
int end_point;
};
pthread_mutex_t lock;
pthread_cond_t ok_to_proceed;
int threads_completed;
} barrier_t;
int N, NUM_THREADS, currentPrime = 2, *primes;
barrier_t barrier;
FILE *file;
pthread_mutex_t pr... | 1 |
#include <pthread.h>
struct atm_log {
uintptr_t i;
uintptr_t thd_id;
uintptr_t c;
void *p;
uintptr_t o;
uintptr_t n;
const char *file;
uintptr_t line;
};
static struct atm_log log_entries[1 << 14];
static uint32_t log_i;
static pthread_mutex_t log_mu;
static pthread_key_t key;
sta... | 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;
struct foo *f_next;
int f_id;
};
struct foo *foo_alloc()
{
struct foo *fp;
int idx;
if((fp = malloc(sizeof(struct foo))) != 0) {
fp-... | 1 |
#include <pthread.h>
int nthreads;
pthread_mutex_t chopstick[50];
FILE *fp = fopen("status.txt", "a");
void thinking(){
int rnd = (random() % 499) + 1;
usleep(rnd);
}
void eating(int threadIndex){
int rnd = (random() % 499) + 1;
fprintf(fp, "Philosopher %d is eating\\n", th... | 0 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
int flag =0 ;
void * pthread_a(void *arga){
fprintf(stderr,"flag a %ld\\n",flag);
pthread_mutex_lock(&mutex);
flag = 1;
fprintf(stderr,"flag a %ld\\n",flag);
pthread... | 1 |
#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(voi... | 0 |
#include <pthread.h>
void init_matrix (int *matrix, int fils, int cols) {
int i, j;
for (i = 0; i < fils; i++) {
for (j = 0; j < cols; j++) {
matrix[i * cols + j] = 1;
}
}
}
int *matrix1;
int *matrix2;
int *matrixR;
int matrix1_fils;
int matrix1_cols;
int matrix2_fils;
int matrix2_col... | 1 |
#include <pthread.h>
pthread_mutex_t value_lock = PTHREAD_MUTEX_INITIALIZER;
int value = 0;
void* thread_func1(void *arg)
{
pthread_mutex_lock(&value_lock);
int count = 1;
while (count++ <= 5) {
value += 1;
printf("thread 1: value = %d\\n", value);
}
pthread_mutex_unlock(&value_lock);
p... | 0 |
#include <pthread.h>
int SendMsgToUser(struct IRCAllUsers *allusers, const char *nick,
const char *msg) {
int ret = 0;
struct IRCUser *ptr;
struct Client *thr_info;
int written, len;
len = strlen(msg);
pthread_mutex_lock(&allusers->lock);
ptr = GetUserPtr(allusers,... | 1 |
#include <pthread.h>
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
int n;
} data;
void print_char_by_char(char *s, int n) {
int i = 0;
while (s[i] != '\\0') {
printf("%c", s[i]);
fflush(stdout);
i++;
struct timespec tim, tim2;
tim.tv_... | 0 |
#include <pthread.h>
char q[5][1024];
char data[1024];
int first = 0;
int last = 0;
int count = 0;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t empty = PTHREAD_MUTEX_INITIALIZER;
void insertQ(char x[], int *first) {
pthread_mutex_lock(&mutex);
strcpy(q[*f... | 1 |
#include <pthread.h>extern void __VERIFIER_error();
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:
__VERIFIER_error();
return;
}
void inc_top(void)
{
top++;
}
void dec_top(void)
{
top--;
}
int get_top(void... | 0 |
#include <pthread.h>
int n = 1, okX = 0, okZ = 0;
pthread_cond_t fimX = PTHREAD_COND_INITIALIZER, fimZ = PTHREAD_COND_INITIALIZER;
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
void X(void *argp)
{
pthread_mutex_lock(&m);
n = n*16;
pthread_cond_signal(&fimX);
okX = 1;
... | 1 |
#include <pthread.h>
struct vring_handle {
unsigned char *buffer;
size_t buffer_size;
size_t max_rw_size;
size_t buffer_len;
size_t read_pos;
size_t write_pos;
pthread_mutex_t mutex;
};
int vring_open(struct vring_handle **handle, size_t buffer_size,
size_t max_rw_size)
{
... | 0 |
#include <pthread.h>
const char *TURNOFF = "OFF";
const char *STOP = "STOP";
const char *START = "START";
const char *SCALE_F = "SCALE=F";
const char *SCALE_C = "SCALE=C";
const char *FREQ = "FREQ=";
const int REQ_PORTNO = 16000;
const int B = 4275;
int PORT_NUM=0;
volatile sig_atomic_t T=3;
vol... | 1 |
#include <pthread.h>
extern void OPENSSL_cleanse(void *ptr, size_t len);
int secure_allocation_support = 0;
static pthread_mutex_t secure_allocation_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_key_t secure_allocation_key;
static const int secure_yes = 1;
static const int secure_no ... | 0 |
#include <pthread.h>
static void
lc_copyHlinks(struct fs *fs) {
struct hldata *hldata = fs->fs_hlinks, *new, **prev = &fs->fs_hlinks;
assert(fs->fs_sharedHlinks);
fs->fs_hlinks = 0;
while (hldata) {
new = lc_malloc(fs, sizeof(struct hldata), LC_MEMTYPE_HLDATA);
ne... | 1 |
#include <pthread.h>
int nthreads,
n,
prime[100000000 + 1],
nextbase;
int work[100];
pthread_mutex_t nextbaselock = PTHREAD_MUTEX_INITIALIZER;
pthread_t id[100];
void crossout(int k)
{
int i;
for (i = k; i * k <= n; i++) {
prime[i * k] = 0;
}
}
void *worker(int tn)
{
int l... | 0 |
#include <pthread.h>
int n_completos = 0;
pthread_mutex_t trava;
int numeros[10];
void* worker(void *arg) {
int *N = (int*)(arg);
int M = (*N);
printf("Iniciando thread %d\\n", M);
int atuador = -1;
while (1) {
pthread_mutex_lock(&trava);
if (n_completos >= 10) break;
... | 1 |
#include <pthread.h>
int numberIndex = 0;
int numThreads = 2;
pthread_mutex_t m1,m2;
long sum = 0;
void *SumUpto(void *arg)
{
int *number = (int *)arg;
int n = *number;
int i;
long threadSum = 0;
pthread_mutex_lock(&m1);
int min = numberIndex;
if(min > n)
... | 0 |
#include <pthread.h>
int args[64] = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10, 11, 12, 13, 14, 15,
16, 17, 18, 19 ,20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52... | 1 |
#include <pthread.h>
{
pthread_t *thread;
pthread_mutex_t cond_lock;
pthread_cond_t cond;
struct _queueNode *prev;
struct _queueNode *next;
} mqNode;
{
mqNode *front, *rear;
pthread_mutex_t queueLock;
} Queue;
Queue Q;
void initQ ()
{
Q.front = 0;
Q.rear = 0;
pthread_mutex_init (&Q.... | 0 |
#include <pthread.h>
int nproc, nthread, play, next;
int flag[6];
time_t start;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
void threadResumeAll() {
pthread_mutex_lock(&mutex);
play = 1;
pthread_cond_signal(&cond);
pthread_mutex_unlock(&... | 1 |
#include <pthread.h>
int broj, obradjeno;
pthread_mutex_t monitor;
pthread_cond_t red_poslova, red_kontrola;
void *posao_n ( void *x )
{
int n;
n = (int) x;
pthread_mutex_lock ( &monitor );
obradjeno++;
if ( obradjeno == 10 )
pthread_cond_signal ( &red_kontrola );
while ( bro... | 0 |
#include <pthread.h>
struct _vector_info{
double *vector_a;
double *vector_b;
double sum;
int length;
};
struct _product{
vector_info_t *info;
int begin_index;
};
pthread_mutex_t mutex;
void dot_product(void *prod)
{
int i;
product_t *p = (product_t *)prod;
vector_info_t *v ... | 1 |
#include <pthread.h>
int account = 0;
int depositamount = 100;
int withdrawamount = 100;
pthread_mutex_t cmutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t condvar = PTHREAD_COND_INITIALIZER;
int deposit(int amount)
{
pthread_mutex_lock(&cmutex);
account = account+amount;
if ... | 0 |
#include <pthread.h>
unsigned degree;
unsigned N;
double* coeffs;
double* dots;
double* answers;
pthread_mutex_t mutex_for_answers;
unsigned num;
} JobInfo;
void* calc_func2(void* arg){
JobInfo* info = arg;
double coeff = coeffs[info->num];
unsigned mydegree = info->num;
u... | 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");
switch... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.