Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
954
6.48k
label
int64
0
1
response
stringclasses
2 values
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <pthread.h> #include <signal.h> #include <unistd.h> //A structure that contains the data // to be passed to a new thread struct DataForThread { char name[36]; int limit; int grouping; }; //This is the function we want to run // in new threads usin...
1
0
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #define NUM_THREADS 4 #define TOTAL_COUNT 10 #define COUNT_LIMIT 12 int count = 0; 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 < TOTAL_COUNT; i++) { ...
0
0
/* filename: timedwait.c purpose: CMPS 360 week 05 - example code Demonstrate the two POSIX thread synchronization primitives - mutex and the condition variable. Demonstrate the condition using the cond_timedwait() function, which you should use instead of sleep since sleep applies to the entire pr...
1
1
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #define THREADS_NUM 3 // Node structure for the list typedef struct List { int value; struct List *next; } List; struct List *lista = NULL; // Initialize list as NULL pthread_mutex_t mutex; sem_t sem; // ...
0
0
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <sys/time.h> #include <sys/resource.h> double get_time(){ struct timeval t; struct timezone tzp; gettimeofday(&t, &tzp); return t.tv_sec + t.tv_usec*1e-6; } void *increment_counter(void *ptr); int counter = 0; pthre...
1
0
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #define BSIZE 4 #define NUMITEMS 30 typedef struct { char buf[BSIZE]; int occupied; int nextin, nextout; pthread_mutex_t mutex; pthread_cond_t more; pthread_cond_t less; } buffer_t; buffer_t buffer; void *producer(void *); void *consumer(void *...
0
0
#include <pthread.h> #include <stdio.h> #include <stdlib.h> int arr[100]; int target; pthread_mutex_t mutex; int found = 0; // Shared variable to indicate if target is found void* binary_search(void* arg) { int* range = (int*) arg; int low = range[0], high = range[1]; if (low > high || found) return NULL...
1
1
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #define NUM_THREADS 3 #define TCOUNT 10 #define COUNT_LIMIT 12 int count = 0; 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 < TCOUNT; i++){ ...
0
0
#include <pthread.h> #include <stdio.h> #include <stdlib.h> int arr[100]; int target; pthread_mutex_t mutex; int found = 0; // Shared variable to indicate if target is found void* binary_search(void* arg) { int* range = (int*) arg; int low = range[0], high = range[1]; if (low > high || found) return NULL...
1
1
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <netinet/in.h> #include <unistd.h> #define FILE_SIZE 671088640 // 800 MB #define BUFFER_SIZE 8 int thread_count = 0; int server_file_des, bytes_read; unsigned long long int block_size = 0, file_pos = 0, t...
0
1
#include <pthread.h> #include <stdio.h> #include <stdlib.h> pthread_mutex_t mutex; int fib_cache[1000]; // Shared cache for memoization void* fibonacci(void* arg) { int n = *(int*) arg; if (n <= 1) return (void*) (size_t) n; pthread_t thread1, thread2; int n1 = n - 1, n2 = n - 2; void* res1; ...
1
1
#include <stdio.h> #include <unistd.h> #include <pthread.h> #include <string.h> #define BUF_SIZE 16 pthread_mutex_t my_mutex; typedef struct Student { char name[BUF_SIZE]; char surname[BUF_SIZE]; int grade; } Student; Student temp; void* fun_write(void *arg) { while (1) { for (int i = 0; i ...
0
0
#include <stdio.h> #include <pthread.h> #include <stdlib.h> int matrice[10][4] = { {8, 25, 3, 41}, {11, 18, 3, 4}, {4, 15, 78, 12}, {1, 12, 0, 12}, {7, 9, 13, 15}, {4, 21, 37, 89}, ...
1
1
#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #define errExit(str) \\ do { perror(str); exit(-1); } while(0) pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static size_t i_gloabl_n = 0; void *thr_demo(void *args) { printf("this...
0
0
#include <stdio.h> #include <stdlib.h> #include <pthread.h> // http://www.cs.cmu.edu/afs/cs/academic/class/15492-f07/www/pthreads.html void *functionC(); pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; int counter = 0; int main() { int rc1, rc2; pthread_t thread1, thread2; /* Create independent thr...
1
1
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #include <string.h> #define CONSUMER_COUNT 2 #define PRODUCER_COUNT 2 typedef struct node_ { struct node_ *next; int num; } node_t; node_t *head = NULL; pthread_t thread[CONSUMER_COUNT + PRODUCER_COUNT]; pthread_cond_t cond; pthr...
0
0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <pthread.h> #include <stdbool.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 ...
1
1
#include <stdio.h> #include <pthread.h> #include <semaphore.h> #include <string.h> #define DATA_MAX 5 #define PRO_INIT_VAL (DATA_MAX / 2) #define CON_INIT_VAL (DATA_MAX - PRO_INIT_VAL) static int data; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static pthread_mutex_t mutex; static sem_t sem_pro; static sem...
0
0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <sys/socket.h> #include <linux/netlink.h> #include <errno.h> struct udp_splice_handle { pthread_mutex_t lock; int sock; uint16_t id; }; static int udp_splice_get_family_id(int sock) { struct { ...
1
0
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include <pthread.h> typedef struct node { int data; struct node* next; }Node; Node *head = NULL; pthread_mutex_t mutex; pthread_cond_t cond; int produced_num = 0; void* th_pro...
0
1
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <pthread.h> #include <linux/spi/spidev.h> #include <string.h> #include <errno.h> // Define the necessary constants #define SPI_MODE SPI_MODE_0 #define SPI_BITS_PER_WORD 8 #define SPI_SPEED_...
1
1
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #define NUM_THREAD 3 #define TCOUNT 5 #define COUNT_LIMIT 7 int count = 0; pthread_mutex_t count_mutex; pthread_cond_t count_threshold_cv; // Increment the count void *inc_count(void *t) { int i; long my_id = (long)t; for ...
0
0
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #define MAX_NODES 10 pthread_mutex_t dist_mutex; int dist[MAX_NODES]; void* dijkstra(void* arg) { int u = *(int*)arg; // Update distances and relax edges for node u printf("Processing node %d\\n", u); // Debug output for testing fr...
1
1
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <fcntl.h> #include <time.h> #include <sys/socket.h> #include <arpa/inet.h> #include <errno.h> char sourceFilename[500], destinationFilename[500]; char nonFlatSourceFilename[500], nonFlatDestinationFilename[500]...
0
1
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <math.h> #include <sys/time.h> #include <string.h> // Global variables pthread_mutex_t minimum_value_lock; long int partial_list_size; int minimum_value; long int *list; long int NumElements, CLASS_SIZE; int NumThreads; void *find_min(void *) ; pth...
1
0
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <unistd.h> #include <sys/time.h> #include <fcntl.h> #include <stdint.h> #include <sys/stat.h> #include <errno.h> static char *root; static int workers; static int trials; static int record_absolute; static struct timeval asbolute...
0
1
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <time.h> // Global variables static int hash_index; static char buffer_postdata[1024 * 1024 * 100]; // static void analysis_web_from_job(struct Job *current_job); static void analysis_web_from_http_list(struct Http_List *list,tim...
1
1
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <sys/socket.h> #include <linux/netlink.h> #include <errno.h> enum mode { MODE_MB, MODE_MEMBARRIER, MODE_COMPILER_BARRIER, MODE_MEMBARRIER_MISSING_REGISTER, }; enum mode mode; struct map_test { int x, y; ...
0
0
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> #include <sched.h> #include <string.h> typedef enum _color { ZERO = 0, BLUE = 1, RED = 2, YELLOW = 3, INVALID = 4, } color; char *colors[] = { "zero", "blue", "red", "yellow", "invalid" }; char *digit...
1
1
/* File: * pth_pool.c * * Purpose: * Implementação de um pool de threads * * * Compile: gcc -g -Wall -o pth_pool pth_pool.c -lpthread -lrt * Usage: ./pth_hello */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <semaphore.h> #include <time.h> #define THREA...
0
0
/* Arquivo: * pth_condition_variable.c * * Propósito: * Demonstrar Condition Variable em C * * * Compile: gcc -g -Wall -o pth_condition_variable pth_condition_variable.c -lpthread -lrt * Usage: ./pth_condition_variable * */ #include <pthread.h> #include <stdio.h> #include <unistd.h> pthread_c...
1
1
#include <pthread.h> #include <unistd.h> #include <stdio.h> #include<math.h> int tickets = 20; pthread_mutex_t mutex; void *mythread1(void) { while (1) { pthread_mutex_lock(&mutex); if (tickets > 0) { usleep(1000); printf("ticketse1 sells ticket:%d\\n", tickets--...
0
0
/* Arquivo: * pth_mutex1.c * * Propósito: * * Input: * nenhum * Output: * * Compile: gcc -g -Wall -o pth_mutex1 pth_mutex1.c -lpthread * Usage: ./pth_mutex1 * */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <string.h> #include <time.h> int pub...
1
1
#include <stdio.h> #include <err.h> #include <stdlib.h> #include <string.h> #include <pthread.h> struct employee { int number; int id; char first_name[32]; char last_name[32]; char department[32]; int root_number; }; /* employees在本程序中是只读的,所以不需要考虑同步问题 */ struct employee employees[] = { { 1, 12345678, "astro"...
0
0
#define _GNU_SOURCE /* To get pthread_getattr_np() declaration */ #include <assert.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; void show_stack(pthread_attr_t *attr, pthread_t thread, char *prefix) { size_t stack_size, guard_siz...
1
1
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <sys/time.h> #include <math.h> #define GRID_SIZE 16384 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;...
0
1
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> enum { QUEUE_BUF_SIZE = 100000, }; typedef struct vector_s { int size; int tail; void **buf; } vector_t; typedef struct queue_cycl_s { int front; int tail; int max_size; void **cyclic_buf; } queue_cycl_t; ...
0
1
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <time.h> #include <stdbool.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 ...
0
0
#include <pthread.h> #include <iostream> #include <unistd.h> using namespace std; #define NUM_THREADS 3 #define TCOUNT 10 #define COUNT_LIMIT 12 int count1 = 0; pthread_mutex_t count_mutex; pthread_cond_t count_threshold_cv; void *inc_count(void *t) { long my_id = (long)t; for (int i = 0; i < TCOUNT; i++) ...
0
0
#include "helper.h" /* * Helper routines for pthreads */ void pclock(char *msg, clockid_t cid) { struct timespec ts; printf("%s", msg); if (clock_gettime(cid, &ts) == -1) { perror("clock_gettime"); return; } printf("%4ld.%03ld\\n", ts.tv_sec, ts.tv_nsec / 1000000); } void errp(c...
0
0
README.md exists but content is empty.
Downloads last month
3