Skip to content

Instantly share code, notes, and snippets.

Michael Cotterell mepcotterell

Block or report user

Report or block mepcotterell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View .gitignore
bin/
doc/
target/
*.class
hs_err_pid*
*~
\#*\#
core.*
View Driver.java
package cs1302.example;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.PriorityQueue;
/**
* Interface example app.
* @see https://docs.oracle.com/javase/8/docs/api/java/util/Queue.html
* @see https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html
@mepcotterell
mepcotterell / README.md
Last active Aug 17, 2019
Implementing a Semaphore
View README.md

Implementing a Semaphore

Use the following commands to compile and link the examples:

$ gcc -std=c17 -pedantic-errors -O0 -g -S sem.c
$ as --gstabs -o sem.o sem.s 
$ gcc -o sem sem.o -lpthread

This implementation makes use of the C11 Atomic Operations Library.

@mepcotterell
mepcotterell / README.md
Last active Aug 17, 2019
Implementing a Mutex
View README.md

Implementing a Mutex

Use the following commands to compile and link the examples:

$ gcc -std=c17 -pedantic-errors -O0 -g -S mutex.c
$ as --gstabs -o mutex.o mutex.s 
$ gcc -o mutex mutex.o -lpthread

This implementation makes use of the C11 Atomic Operations Library.

@mepcotterell
mepcotterell / README.md
Last active Aug 17, 2019
Critical Section Problem
View README.md

Critical Section Problem

Use the following commands to compile and link the examples:

$ gcc -std=c17 -pedantic-errors -O0 -g -o problem problem.c -lpthread
$ gcc -std=c17 -pedantic-errors -O0 -g -o peterson0 peterson0.c -lpthread
View gcd.s
/* This file contains an unoptimized, recursive GCD implementation. */
/* The code assumes %rdi and %rsi will be unsigned... if signed, then cqto will be needed to sign-extend %rax to %rdx:%rax. */
/* What are some ways to optimize it? */
.data
fmtstr:
.ascii "%d\n"
.text
.globl gcd
View eflags.md

%eflags

Flags

Flag Description
CF Carry Flag
PF Parity Flag
AF Adjust Flag
ZF Zero Flag
View getitimer.2.md

Interval Timer Notes

The system provides each process with three interval timers, each decrementing in a distinct time domain. When any timer expires, a signal is sent to the process, and the timer (potentially) restarts.

Timers will never expire before the requested time, but may expire some (short) time afterwards, which depends on the system timer resolution and on the system load; see time(7). Upon expiration, a signal will be generated and the timer reset.

@mepcotterell
mepcotterell / syscall_asm.md
Last active Feb 10, 2019
Sytstem Call Notes
View syscall_asm.md

System Call Notes

Invoking System Calls

To invoke a system call:

  1. Set %rax to the system call number (see Full Table below);
  2. Set %rdi, %rsi, %rdx, %r8, %r10, %r9 (in order) according to the glibc prototype given in the manual; then
  3. Perform syscall instruction.
You can’t perform that action at this time.