Skip to content

Instantly share code, notes, and snippets.

View radito3's full-sized avatar
🏢

Rangel Ivanov radito3

🏢
  • SAP Labs Bulgaria
  • Sofia, Bulgaria
View GitHub Profile
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysinfo.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h>
double get_cpu_utilization() {
@radito3
radito3 / dining_philosophers.c
Last active May 23, 2020 15:22
C program for an Arbitrator solution to the Dining Philosophers synchronization problem
#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>
#include <unistd.h>
#define N 5
#define LEFT(X) ((X) + 4) % N
#define RIGHT(X) ((X) + 1) % N
typedef enum { EATING, HUNGRY, THINKING } ph_states;