01-tp-c

Upload: andre-perdigao

Post on 07-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 01-TP-C

    1/6

    Department of Informatics EngineeringFCTUCUniversity of Coimbra

    Operating Systems TP lessons Instructors

    Bruno Cabral, [email protected], Wednesday11:00/12:00, 0.1.9 Alcides Fonseca, [email protected], 7, 0.7.7

    Outline of TP lessons Discussion of assignments Resolution of problems and questions Support and assistance to students assignments

    mailto:[email protected],mailto:[email protected],mailto:[email protected],mailto:[email protected],
  • 8/3/2019 01-TP-C

    2/6

    Assignment and projects Initial assignment - not evaluated. 3 small projects - 6 points

    - #1: Unix; Processes; Files; Signals; Pipes; Select- #2: Processes; Shared Memory; Semaphores; MMF- #3: Threads; Synchronisation; Condition Variables; Drivers

    Minimum 2 on the three projects Groups of 2 students Submissions in mood/e. dei. uc.pt -7 key=SO_2011 No submissions after deadline Student-worker status - also submit projects PL classes: grading (3) Written test: 14 Dec (3)

    Assignment and projects.Cooperation and Cheating

    -Feel free to discuss assignments with other members ofthe class, the teachers or someone else.-Do not look at or copy another students solution to anassignment.-Once you understand the problem, and have thebackground necessary to solve it, you must provide yourown solution.-Exchanging assignment solutions is cheating and will leadto the fail in the course .

    Works submitted will be tested for plagiarism!(MOSS)

  • 8/3/2019 01-TP-C

    3/6

    Evaluation- Theory

    Written test = 14- Theory (10, min 3) and practice (4, min 1.5)

    - Practice Written test = 3- Functional requirements = 3- MIN: 2

    Class materials-In the Inforestudante web page

    SlidesAssignments.Other support material

    -Useful books K. A. Robbins, S. Robbins, "Unix Systems Programming:Communication, Concurrency, and Threads", 2n d Edition,Prentice Hall.W. Richard Stevens, Stephen A. Rago "AdvancedProgramming in the UNIX Environment" 2n d Edition,Addison-Wesley

  • 8/3/2019 01-TP-C

    4/6

    TP 01 - Contents Linux shell basic commands

    man; Is; mkdir; rm; ep; mv; ehmod; cat; less; we; ps; ... Notes on linux shell commands available on WOC

    Compiling C programs gee; make ~ or IDE (CodeBloeks; Geany; ... ) Notes on makefiles available on WOK

    Debugging gdb; ddd Discussion of the first assignment Linked lists Files

    Notes on reading and writing to files available on woe

    Compiling C Programs#include #include void 5w ap( int * 0, in t *d){

    in t t;t = *0;*0 = *d;'d ~ t;

    int main(void) {int n ~ {I, 4, 2, 3, 7, 6);int 'array corrente ~ NULL;printf("Orlginal array:\n");print array(x,sizeof(x)/sizeof(int));quicksort (array corrente,8, sizeof (x) I sizeof (int) -II ;print f ("Ordered-array: \n" 1;print array(x,sizeof(x)/sizeof(int)l;return 0;

    int partition(int s(J, int 1, int h){in t i;int firsthigh;first hi gh = 1;for (1 = 1; i < h; Lri )if (s[iJ -c s[h]){

    swap(&s[iJ, &s[firsthighJ);fi rsthigh++;

    }swap(&s[hJ, &s[firsthighJI;return firsthigh; gcc -Wall -g trab01.c -0 trabOl

    But ... what to do when we havemore than one source file? Long commands ...

    gcc -Wall -g ... -c Object files" .0"

    in t qUicksort(int s[], in t 1, in t h){in t p;if ((h-1) > 8){

    P = partitlon(s, 1, h);quicksort(s, 1, p-II;qUicksort(s, p+l, h);

    }return 8;

    void pr int arr ay(i nt s[ ], in t n) {in t i; -for (i ~ 8; i < n-I; i++){printf("%d, ''. s[iJI;}printf ("%d\n", s [n-I J I;

  • 8/3/2019 01-TP-C

    5/6

    Compiling C ProgramsFLAGSCCPROGOBJS

    -WaH -ggeetrab82t ra b8 2. 0 q ue ue .o

    makefiler m $ {O BJ S} $ {P RO G} * -

    ${P RO G} : ${ OBJS}$ {C C} $ {F LA GS } $ {O BJ S} -0 $@

    all: ${PROG}clean:

    .c. 0: ${CC} ${FLAGS} $< -c##########################

    queue.o: queue.h queue.ctrab 82 .0: q ue ue .h trab 82 .ctrab 82 : q ue ue .o trab 82 .0

    Debugging gcc - g ...gdb; ddd

    DDD: /homeJbcabral/my_files{temp/demos_so_Ol/trabOl.c

    f _r og ra m C om m an ds Stane _o ur ce D at a

    1, main () at trab01.c:46

    core files ulimit -c unlimited

  • 8/3/2019 01-TP-C

    6/6

    Assignment #00 L inked Lists

    Example Double linked lists

    list 30 I 20'nehalue next value

    L r 10 I NULLvalue nexttypedef struct

    int value;item {

    structstruct

    } item;

    item* next;item* previous;

    item* list;

    Assignment #00 F iles

    Reading and writing: Low level: openO/closeO/readO/writeO High level: fopenO/fcioseO/fprintfO/fscanfO/freadO

    Example

    F inally ... the assignment!