← Indietro
EsameEsame completoTesto d’esame

01 07 15

Esame completo di Advanced Operating Systems per il corso di Computer Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Advanced Operating SystemsEsame completo

Informazioni sul documento

Cosa trovi in questo materiale

Esame completo di Advanced Operating Systems per il corso di Computer Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Qualità dell’importazione: il testo è stato estratto direttamente dal documento originale.

Contenuti estratti dal documento

Passaggi rappresentativi riconosciuti nelle diverse parti del materiale. Il testo completo resta presente nella pagina per la ricerca, mentre l’anteprima compatta rende più semplice la lettura.

Pagina 1

Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL’INFORMAZIONE Advanced Operating Systems A.A. 2014-2015 – Exam date: 1 July 2015 Prof. William FORNACIARI Surname (readable)........................................ Name (readable)............................ Matr................................................................. Signature........................................ Q1 Q2 Q3 TOT NOTES It is forbidden to refer to texts or notes of any kind as well as interact with their neighbors. Anyone found in possession of documents relating to the course, although not directly relevant to the subject of the examination will cancel the test. It is not allowed to leave during the first half hour, the task must still be returned, even if it is withdrawn. The presence of the writing (not delivered) implies the renunciation of any previous ratings. Question Q1 Describe what is a context switch by specifying its purposes and detailing a generic and common implementation. 1/9 Question Q2 Consider the following multithreaded C program. 1) Describe the program flow from start to finish detailing the synchronizations that happen between the threads. 2) Write what the program prints on the standard output. 3) Fix the bug in the program. #include <stdio.h> #include <stdlib.h> #include <pthread.h> struct Param { int *slice; int size; int *result; }; void *thread(void *arg) { struct Param *p=(struct Param*)arg; int i; int sum=0; for(i=0;i<p­>size;i++) sum+=p­>slice[i]; *(p­>result)+=sum; free(p); return NULL; } int main() { const int N=10; int data[N][N]; int i,j; for(i=0;i<N;i++) for(j=0;j<N;j++) data[i][j]=i+j; int result=0; pthread_t threads[N]; for(i=0;i<10;i++) { struct Param *p=(struct Param*)malloc(sizeof(struct Param)); p­>slice=data[i]; p­>size=N; p­>result=&result;…

Anteprima

Prima pagina del documento.

Prima pagina: 01 07 15