diff --git a/bac2/os/chap3/Makefile b/bac2/os/chap3/Makefile index 160b8a9..4cf7ec5 100644 --- a/bac2/os/chap3/Makefile +++ b/bac2/os/chap3/Makefile @@ -2,7 +2,10 @@ CC = gcc CFLAGS = -g -Wall -all: ex1 ex2 ex3 ex4 ex5 +all: ex1 ex2 ex3 ex4 ex5 ex6 ex7 group + +group: group.o mergeSort.o + $(CC) $(CFLAGS) -o $@ $+ %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< @@ -16,7 +19,7 @@ clean: mrproper: clean rm -f ex1 -run: ex6 +run: group ./$< graph: run diff --git a/bac2/os/chap3/ex7.c b/bac2/os/chap3/ex7.c new file mode 100644 index 0000000..c6ec7c0 --- /dev/null +++ b/bac2/os/chap3/ex7.c @@ -0,0 +1,6 @@ +#include + +int main(void) +{ + printf("Hello World!\n"); +} diff --git a/bac2/os/chap3/group.c b/bac2/os/chap3/group.c new file mode 100644 index 0000000..9ac9c6f --- /dev/null +++ b/bac2/os/chap3/group.c @@ -0,0 +1,23 @@ +#include "mergeSort.h" + +#include +#include +#include + +#define printlist(s, x) printf("%s = [", #x); for (int i = 0; i < s; ++i) { printf("%d, ", x[i]); } printf("\b\b]\n"); + +#define listSize 10000000 +int list[listSize]; + +int main(void) +{ + srand(time(NULL)); + for (int i = 0; i < listSize; ++i) { + list[i] = rand(); + } + /* printlist(listSize, list); */ + + margs_t args = {list, 0, 9}; + merge_sort(&args); + printlist(listSize, list); +} diff --git a/bac2/os/chap3/mergeSort.c b/bac2/os/chap3/mergeSort.c new file mode 100644 index 0000000..899baf9 --- /dev/null +++ b/bac2/os/chap3/mergeSort.c @@ -0,0 +1,58 @@ +#include "mergeSort.h" + +#include +#include +#include + +#define THREADS + +pthread_t threads[THREADS]; + +void* merge_sort(void* args) { + margs_t* f = (margs_t*) args; + if(f->start < f->final) { + pthread_t t1, t2; + index middle = (f->start + f->final) / 2; + + margs_t args1 = {f->array, f->start, middle}; + assert(!pthread_create(&t1, NULL, merge_sort, (void*) &args1)); + margs_t args2 = {f->array, middle+1, f->final}; + assert(!pthread_create(&t2, NULL, merge_sort, (void*) &args2)); + + assert(pthread_join(t1, NULL)); + assert(pthread_join(t2, NULL)); + merge(f->array, f->start, middle, f->final); + } + int *ret = 0; + return ret; +} + +void merge(int array[], index start, index middle, index final) { + + length countL = middle - start + 1; + int *arrayL = malloc(countL * sizeof(int)); + for(index currentL = 0; currentL < countL; currentL ++) + arrayL[currentL] = array[start + currentL ]; + + length countR = final - middle; + int* arrayR = malloc(countR * sizeof(int)); + for(index currentR = 0; currentR < countR; currentR ++) + arrayR[currentR] = array[middle + 1 + currentR ]; + + index currentL, currentR, current; + for(currentL = 0, currentR = 0, current = start; + current <= final && currentL < countL && currentR < countR; + current ++) + if(arrayL[currentL] <= arrayR[currentR]) + array[current] = arrayL[currentL++]; + else + array[current] = arrayR[currentR++]; + + while(currentR < countR) + array[current++] = arrayR[currentR++]; + while(currentL < countL) + array[current++] = arrayL[currentL++]; + + free(arrayL); + free(arrayR); +} diff --git a/bac2/os/chap3/mergeSort.h b/bac2/os/chap3/mergeSort.h new file mode 100644 index 0000000..9453966 --- /dev/null +++ b/bac2/os/chap3/mergeSort.h @@ -0,0 +1,15 @@ +#pragma once + +typedef unsigned int index; +typedef unsigned int length; + +typedef struct merge_args{ + int* array; + index start; + index final; +} margs_t; + + +void merge(int array[], index start, index middle, index final); +/* void merge_sort(int array [], index start , index final ); */ +void* merge_sort(void*); diff --git a/bac2/pgl/usecase/extension_messagerie.tex b/bac2/pgl/usecase/extension_messagerie.tex new file mode 100644 index 0000000..464b933 --- /dev/null +++ b/bac2/pgl/usecase/extension_messagerie.tex @@ -0,0 +1,32 @@ +\documentclass{article} + +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{amsmath, amsfonts, amssymb, amsthm} +\usepackage{tikz} + +\author{Debucquoy Anthony} +\title{Extension messagerie} + +\begin{document} + +\section{Use case diagram} + +\begin{center} +\resizebox{390pt}{!}{ + \input{./use_case_messagerie.tex} +} +\end{center} + +\subsection{Answer topic} +\subsection{Create discutions} +\subsubsection{Send messages} +\subsection{Ask apointment} +\subsubsection{Export to calendar} +\subsection{Manage apointment} +\subsubsection{Propose new apointment} +\subsection{Create forum} +\subsubsection{Post topics} +\subsubsection{Post poll} + +\end{document} diff --git a/bac2/pgl/usecase/use_case_messagerie.uml b/bac2/pgl/usecase/use_case_messagerie.uml new file mode 100644 index 0000000..c2f39af --- /dev/null +++ b/bac2/pgl/usecase/use_case_messagerie.uml @@ -0,0 +1,39 @@ +@startuml + +left to right direction + +:Student: as s +:Teacher: as t + + +package "Messagerie"{ + +(Answer topics) as at +(Ask apointement) as aa +(Create Discution) as cd +(Create Forum) as cf +(Manage apointement) as ma + +s -- at +s -- aa +s -- cd + +t -- cd +t -- cf +t -- ma + +(Export to calendar) as etc + +aa <-- etc : << extend >> +ma <-- etc : << extend >> + +(Post topics) as pt +cf <-- pt : << include >> +pt <|-- (Post poll) +cd <-- (Send messages) : << include >> + +ma <-- (Propose new appointment) : << exlude>> \n [refuse] + +} + +@enduml