- Timestamp:
- Apr 18, 2014, 8:10:14 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile
r15 r26 1 1 TARGET_ARCH=-m32 2 2 ASM=nasm 3 CFLAGS=-masm=intel -Wall 3 4 4 5 mioboot: mioboot.asm … … 17 18 esercizio: esercizio.o 18 19 19 pthreads-pc : LDFLAGS=-lrt20 pthreads-pc rw rw-nosync rw-mutex rw-rlotto: LDFLAGS=-lpthread 20 21 21 22 pthreads-pc: pthreads-pc.c … … 33 34 threads-tsl: threads-tsl.o enter.o 34 35 36 threads-tsl-new: threads-tsl-new.c 37 38 %.tex : %.nw 39 noweave -delay -filter btdefn -index -filter "awk -f lst.awk|tee debug" $< > $@ 40 41 %.c : %.nw 42 notangle -R$@ -filter btdefn $< > $@ 43 44 %.pdf : %.tex 45 pdflatex $< && pdflatex $< && pdflatex $< 35 46 36 47 .PHONY: clean -
trunk/enter.asm
r2 r26 6 6 mov ebx,[ebp+8] ; first parameter to function 7 7 8 9 ;; bts bitbase bitoffset 10 ;; selects the bitoffset bit in bitbase, 11 ;; stores the value in the CF flag, and sets the bit to 1 8 12 spin: lock bts dword [ebx], 0 9 13 jc spin -
trunk/enter2.asm
r2 r26 8 8 9 9 10 spin: mov ecx, 0 10 spin: push busy 11 call printf 11 12 lock bts dword [ebx], 0 12 jc save 13 print: push busy 14 call printf 13 jc spin 15 14 16 cmp ecx, 117 je spin18 19 save: mov ecx, 120 jmp print21 22 15 leave ; mov esp,ebp / pop ebp 23 16 ret -
trunk/filefigli.c
r24 r26 34 34 } 35 35 lsofd("padre (senza figli)"); 36 if (write(f, string, (strlen(string) +1)) != (strlen(string)+1) ){36 if (write(f, string, (strlen(string))) != (strlen(string)) ){ 37 37 perror("write"); 38 38 exit(1); -
trunk/forca.c
r2 r26 6 6 int x = fork(); 7 7 if (x < 0){ 8 9 10 } else {11 12 while(1) printf("Processo padre (Figlio:%d)\n", x);13 } else {14 while(1) printf("Processo figlio (%d)\n", x);15 }8 perror("Errore nella fork:"); 9 exit(1); 10 } 11 if (x != 0){ 12 while(1) printf("Processo padre (x == %d)\n", x); 13 } 14 else { // x == 0 15 while(1) printf("Processo figlio (x == %d)\n", x); 16 16 } 17 17 return 0; 18 18 } 19 20 21 22 -
trunk/hello.c
r6 r26 1 /* Copyright (C) 2014 by Mattia Monga <mattia.monga@unimi.it> */ 2 /* $Id$ */ 3 1 4 #include <stdio.h> 2 #include <unistd.h>3 #include <stdlib.h>4 5 5 int main(void){ 6 int i; 7 for (i=0; i<10; i++){ 8 printf("Hello world! (%d)\n", i+1); 9 sleep(1); 10 } 11 exit(0); 6 int main(){ 7 printf("Ciao %d %s", 5, "mamma"); 8 asm("mov eax, 0"); 9 return 0; 12 10 } 11 12 /* Local Variables: */ 13 /* compile-command: "make -k " */ 14 /* End: */ -
trunk/hello.s
r24 r26 1 1 .file "hello.c" 2 .intel_syntax noprefix 2 3 .section .rodata 3 4 .LC0: 4 .string "Hello world! (%d)\n" 5 .string "mamma" 6 .LC1: 7 .string "Ciao %d %s" 5 8 .text 6 9 .globl main … … 9 12 .LFB0: 10 13 .cfi_startproc 11 push l %ebp14 push ebp 12 15 .cfi_def_cfa_offset 8 13 16 .cfi_offset 5, -8 14 mov l %esp, %ebp17 mov ebp, esp 15 18 .cfi_def_cfa_register 5 16 andl $-16, %esp 17 subl $32, %esp 18 movl $0, 28(%esp) 19 jmp .L2 20 .L3: 21 movl 28(%esp), %eax 22 addl $1, %eax 23 movl %eax, 4(%esp) 24 movl $.LC0, (%esp) 19 and esp, -16 20 sub esp, 16 21 mov DWORD PTR [esp+8], OFFSET FLAT:.LC0 22 mov DWORD PTR [esp+4], 5 23 mov DWORD PTR [esp], OFFSET FLAT:.LC1 25 24 call printf 26 movl $1, (%esp) 27 call sleep 28 addl $1, 28(%esp) 29 .L2: 30 cmpl $9, 28(%esp) 31 jle .L3 32 movl $0, (%esp) 33 call exit 25 #APP 26 # 8 "hello.c" 1 27 mov eax, 0 28 # 0 "" 2 29 #NO_APP 30 mov eax, 0 31 leave 32 .cfi_restore 5 33 .cfi_def_cfa 4, 4 34 ret 34 35 .cfi_endproc 35 36 .LFE0: 36 37 .size main, .-main 37 .ident "GCC: (Debian 4. 7.2-5) 4.7.2"38 .ident "GCC: (Debian 4.8.2-18) 4.8.2" 38 39 .section .note.GNU-stack,"",@progbits -
trunk/mioboot-nobios-simple.asm
r3 r26 1 ;Copyright (C) 2008 -2011by Mattia Monga <mattia.monga@unimi.it>1 ;Copyright (C) 2008, 2009 by Mattia Monga <mattia.monga@unimi.it> 2 2 bits 16 ; 16 bit real mode 3 3 org 0x7C00 ; origine indirizzo 0000:7C00 -
trunk/pthreads-pc.c
r8 r26 1 /* Copyright (C) 2008 by Mattia Monga <mattia.monga@unimi.it> */1 /* Copyright (C) 2008, 2014 by Mattia Monga <mattia.monga@unimi.it> */ 2 2 /* $Id$ */ 3 3 #include <pthread.h> … … 13 13 while (1){ 14 14 char* o = (char*)malloc(sizeof(char)); 15 printf("Ho prodotto % x\n", o);15 printf("Ho prodotto %p\n", o); 16 16 b_insert(o); 17 17 } … … 25 25 b_remove(&o); 26 26 free(o); 27 printf("Ho consumato % x\n", o);27 printf("Ho consumato %p\n", o); 28 28 } 29 29 return NULL; … … 56 56 57 57 while (count == N) pthread_cond_wait(&full, &lock); 58 printf("Buffer a %d\n", count); 58 59 buffer[count++] = o; 59 60 if (count == 1) pthread_cond_signal(&empty); … … 68 69 69 70 while (count == 0) pthread_cond_wait(&empty, &lock); 71 printf("Buffer a %d\n", count); 70 72 *result = buffer[--count]; 71 73 if (count == N-1) pthread_cond_signal(&full); -
trunk/syscall.asm
r22 r26 1 1 segment .text 2 2 global main 3 extern printf4 3 5 main: push msg 6 call printf ; chiamata di libreria 7 8 mov ecx, msg ; stringa 4 main: mov ecx, msg ; stringa 9 5 mov edx, msg_size ; dimensione stringa 10 6 mov ebx, 1 ; file descriptor (stdout) -
trunk/threads-peterson.c
r15 r26 1 1 /* Copyright (C) 2009 by Mattia Monga <mattia.monga@unimi.it> */ 2 2 /* $Id$ */ 3 3 #define _GNU_SOURCE 4 4 #include <unistd.h> 5 5 #include <stdio.h> -
trunk/threads-shared.c
r15 r26 1 1 /* Copyright (C) 2009 by Mattia Monga <mattia.monga@unimi.it> */ 2 2 /* $Id$ */ 3 3 #define _GNU_SOURCE 4 4 #include <unistd.h> 5 5 #include <stdio.h> -
trunk/threads-tsl.c
r15 r26 1 1 /* Copyright (C) 2009 by Mattia Monga <mattia.monga@unimi.it> */ 2 2 /* $Id$ */ 3 #define _GNU_SOURCE 3 4 4 5 #include <unistd.h> … … 18 19 printf("Processo figlio (%d). s = %d\n", 19 20 getpid(), shared[0]); 21 fflush(stdout); 20 22 if (!(shared[0] < 10)){ 21 23 printf("Corsa critica!!!!\n"); … … 25 27 leave_section(&shared[1]); 26 28 sched_yield(); 29 usleep(50); 27 30 } 28 31 leave_section(&shared[1]); // il test nel while \`e dopo enter\_section … … 71 74 shared[2], 72 75 shared[3]); 76 fflush(stdout); 73 77 } 74 78 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.