This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# adapted from http://code.activestate.com/recipes/577504-compute-memory-footprint-of-an-object-and-its-cont/ | |
# | |
from __future__ import print_function | |
from sys import getsizeof, stderr | |
from itertools import chain | |
from collections import deque | |
try: | |
from reprlib import repr | |
except ImportError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <pthread.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#define NPHIL 5 | |
#define MAXFOOD 50 | |
#define MAXTHINK 5 | |
#define SPAGHETTI_SPEED_SERVE 5000 // in microseconds | |
#define SPAGHETTI_SPEED_EAT 10000 // in microseconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <pthread.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#define PROD_DELAY 1000 // in microseconds | |
#define CONS_DELAY 1000 // in microseconds | |
int buf_items; // implementing unbounded buffer | |
pthread_mutex_t mutex; |