export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS
This file contains hidden or 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
%% @doc A binary tree implementation in Erlang. | |
%% A binary tree stores keys and values. | |
-module(binary_tree). | |
-export([init/0, init/1, insert/3, lookup/2]). | |
-define(EMPTY_NODE, {node, 'empty'}). | |
%% @doc Initialize an empty binary tree node. | |
%% This is how the root of the tree should be established. | |
%% |
This file contains hidden or 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
/* | |
* Copyright (c) 2013 Landon Fuller <landonf@mac68k.info> | |
* All rights reserved. | |
*/ | |
/* Interface to the native pcap(3) library */ | |
package pcap | |
/* | |
#cgo LDFLAGS: -lpcap |
This file contains hidden or 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 <stdio.h> | |
/* this function is run by the second thread */ | |
void *inc_x(void *x_void_ptr) | |
{ | |
/* increment x to 100 */ | |
int *x_ptr = (int *)x_void_ptr; | |
while(++(*x_ptr) < 100); |
This file contains hidden or 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 <stdio.h> | |
#include <unistd.h> | |
#include <assert.h> | |
/* Compile like this: | |
gcc --std=c99 -lpthread cond.c -o cond |
This file contains hidden or 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
// gcc setspecific.c -lpthread | |
/* | |
Enter Testcase - ./a.out | |
Create a thread local storage key | |
pthread_key_create() | |
========> rc: 0 | |
Create 3 threads using joinable attributes | |
pthread_create() | |
========> rc: 0 | |
==> Inside secondary thread |
This file contains hidden or 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
/* | |
$ gcc tls.c -o tls -lpthread | |
$ ./tls | |
1 is runing in thread_func | |
100 is runing in show | |
2 is runing in thread_func | |
200 is runing in show | |
*/ |
This file contains hidden or 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
/* | |
https://en.wikipedia.org/wiki/Time_Stamp_Counter | |
https://ru.wikipedia.org/wiki/Rdtsc | |
*/ | |
#include <stdio.h> | |
typedef unsigned long long uint64; | |
int main() { |
This file contains hidden or 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 <stdlib.h> | |
#include <stdio.h> | |
#include <getopt.h> | |
#include <unistd.h> | |
#include <math.h> // used to help calculate set and block | |
#include "cachelab.h" | |
/* | |
* Simulates a cache logic with a write-back and LRU (least recently used) policy. | |
* Handles direct-mapped, set-associative and full-associative caches. |
This file contains hidden or 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
#!/bin/bash | |
echo '[info-]> Install netmap on Ubuntu' | |
# Update system | |
echo '[info-]> Updating system...' | |
apt-get update | |
# Install dependencies | |
echo '[info-]> Installing dependencies ...' |