Skip to content
Snippets Groups Projects
Commit ce6a4bd9 authored by Horea Christian's avatar Horea Christian
Browse files

Merge branch 'master' of gitlab.ethz.ch:thealternative/courses

parents d7ef5404 227fde5a
No related branches found
No related tags found
No related merge requests found
Showing
with 134 additions and 0 deletions
#!/bin/bash
printf "Building Main Presentation... "
pandoc -t beamer --template template.tex --listings pres.md -o pres.pdf --pdf-engine pdflatex
echo "Done"
File added
File added
File added
int
main(int argc, char **argv) {
int arr[10];
arr[11] = 1;
return 0;
}
File added
#include<pthread.h>
pthread_mutex_t lock1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t lock2 = PTHREAD_MUTEX_INITIALIZER;
void *
thread1(void *arg __attribute__((unused))) {
pthread_mutex_lock(&lock1);
pthread_mutex_lock(&lock2); //Lock-Order-Inversion between here...
pthread_mutex_unlock(&lock2);
pthread_mutex_unlock(&lock1);
return NULL;
}
void *
thread2(void *arg __attribute__((unused))) {
pthread_mutex_lock(&lock2);
pthread_mutex_lock(&lock1); // ... and here!
pthread_mutex_unlock(&lock1);
pthread_mutex_unlock(&lock2);
return NULL;
}
int
main(int argc, char **argv) {
pthread_t t1, t2;
pthread_create(&t1, NULL, thread1, NULL);
pthread_create(&t2, NULL, thread2, NULL);
pthread_join(t1, NULL);
pthread_join(t2, NULL);
return 0;
}
File added
#include<stdlib.h>
int
main(int argc, char **argv) {
int *p;
p = malloc(sizeof(int));
return 0;
}
File added
#include<pthread.h>
volatile int inc;
void *
thread(void *arg __attribute__((unused))) {
for (int i = 0; i < 65536; i++)
inc++;
return NULL;
}
int
main(int argc, char **argv) {
pthread_t t1, t2;
pthread_create(&t1, NULL, thread, NULL);
pthread_create(&t2, NULL, thread, NULL);
pthread_join(t1, NULL);
pthread_join(t2, NULL);
return 0;
}
File added
#include<stdlib.h>
int
main(int argc, char **argv) {
int *ip;
ip = malloc(sizeof(int));
free(ip);
*ip = 3;
return 0;
}
int
main(int argc, char **argv) {
int i = 32;
int j = 0xCAFFEE;
j = j << i;
return 0;
}
File added
#include<stdio.h>
int
main(int argc, char **argv) {
int i;
if (i)
printf("Hui\n");
else
printf("Pfui\n");
return 0;
}
File added
#include<stdio.h>
#include<stdbool.h>
#include<tgmath.h>
bool
is_prime(int number) {
int max = ((int) sqrt((double) number)) + 1;
for (int i = 2; i < max; i++)
if (!(number % i))
return false;
return true;
}
int
main(int argc, char** argv) {
int number;
scanf("%d", &number);
if (is_prime(number))
printf("%d: prime\n", number);
else
printf("%d: not prime\n", number);
return 0;
}
File added
#include<stdio.h>
int
main(int argc, char **argv) {
FILE *f = fopen("/tmp/test", "w+");
fprintf(f, "Hello\n");
fclose(f);
printf("Done!\n");
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment