Topic 6: Threads * K24: Systems Programming Instructor: Mema Roussopoulou

Μέγεθος: px
Εμφάνιση ξεκινά από τη σελίδα:

Download "Topic 6: Threads * K24: Systems Programming Instructor: Mema Roussopoulou"

Transcript

1 Topic 6: Threads * K24: Systems Programming Instructor: Mema Roussopoulou

2 Threads -Νήµατα Lightweight Processes (LWPs) share single address space, each has its own flow control Try to overcome penalties separate process for every flow of of control is costly Offer a more efficient way to develop apps on uniprocessor, one thread blocks on a syscall (e.g., read), another grabs CPU and does useful processing (faster user interface, lower program execution time) on multiprocessor, separate thread on each CPU (program finishes faster) 2

3 Νήµατα -Μοντέλο Two-level multi-threaded Model 3

4 Νήµατα Πολύσηµαντικό 4

5 Νήµατα (συν.) gcc o <filename> <filename>.c -pthread Σηµαντικό 5

6 Threads vs. Processes Νήµατα ιεργασίες Χώρος εδοµένων Περιγραφείς Αρχείων fork exit exec Σήµατα Κοινός. Ότι αλλάζει το 1 νήµα το βλέπουν/ αλλάζουν και τα άλλα (πχ malloc/free) Κοινοί. 2 νήµατα χρησιµοποιούν ίδιο περιγραφέα. Αρκεί 1 close σεαυτόν. Ξεχωριστός. Ξεχωριστός χώρος διευθύνσεων µετά το fork Αντίγραφα. 2 διεργασίες χρησιµοποιούν αντίγραφα του περιγραφέα. Μόνοτονήµαπουκάλεσε forkαντιγράφεται. Όλα τα νήµατα πεθαίνουν µαζί (pthread_exit για τερµατισµό µόνο ενός νήµατος) Όλα τα νήµατα εξαφανίζονται (αντικαθίσταται ο κοινός χώρος διευθύνσεων) Περίπλοκο. Κοιτάξτε βιβλίο. Κάποια πάνε στο νήµα που τα προκάλεσε, κάποια στο πρώτο που δεν έχει µπλοκάρει 6

7 ηµιουργίακαι ΤερµατισµόςΝηµάτων Χαρακτηριστικό νήµατος. (Μπορεί να γίνει join) Αποφύγετεεπιστροφήδείκτησεαυτόµατεςµεταβλητές. Προτιµήστε δείκτη σε δεδοµένα δηµιουργηµένα από malloc 7

8 Συναρτήσεις pthread_join, pthread_detach, pthread_self Θυµίζει την waitpid σε διεργασίες Έλεγχος ισότητας pthread_t µε pthread_equal Σηµαντικό: ΕΝ τερµατίζεται το νήµα. Απλά δηλώνει ότι θα αποδεσµευτούν οι πόροι του ΌΤΑΝ τερµατίσει 8

9 Χρήση pthread_create, pthread_exit, pthread_join και pthread_self #include <stdio.h> #include <string.h> /* For strerror */ #include <stdlib.h> /* For exit */ #include <pthread.h> /* For threads */ #define perror2(s,e) fprintf(stderr, "%s: %s\n", s, strerror(e)) void *thread_f(void *argp){ /* Thread function */ printf("i am the newly created thread %ld\n", pthread_self()); pthread_exit((void *) 47); main(){ pthread_t thr; int err, status; /* New thread */ Not recommended way of exit ing.. avoid using automatic values; use malloc(ed) structs to return status if (err = pthread_create(&thr, NULL, thread_f, NULL)) { perror2("pthread_create", err); exit(1); printf("i am original thread %ld and I created thread %ld\n", pthread_self(), thr); /* Wait for thread */ if (err = pthread_join(thr, (void **) &status)) { perror2("pthread_join", err); /* termination */ exit(1); printf("thread %ld exited with code %d\n", thr, status); printf("thread %ld just before exiting (Original)\n", pthread_self()); pthread_exit(null); 9

10 Run output I am the newly created thread I am original thread and I created thread Thread exited with code 47 Thread just before exiting (Original) mema@bowser> 10

11 whichexit() can be executed as a thread void *whichexit(void *arg){ int n; int np1[1]; int *np2; char s1[10]; char s2[] = "I am done"; n = 3; np1 = n; np2 = (int *)malloc(sizeof(int *)); *np2 = n; strcpy(s1,"done"); return(null); 1. n 2. &n 3. (int *)n 4. np1 5. np2 6. s1 7. s2 8. This works 9. strerror(eintr) Which of the above options could be safe replacement for NULL as return value in whichexit function? (Or as a parameter to pthread_exit?) 1. No, return value is a pointer not an int 2. No automatic variable 3. Might work (but not in all impls- avoid) 4. No automatic variable 5. Yes dynamically allocated 6. No automatic variable 7. No automatic storage 8. Yes In C, string literals have static storage 9. No The string produced by strerror might not exist 11

12 Χρήση pthread_detach #include <stdio.h> #include <string.h> #include <stdlib.h> #include <pthread.h> #define perror2(s,e) fprintf(stderr,"%s: %s\n",s,strerror(e)) void *thread_f(void *argp){ /* Thread function */ int err; if (err = pthread_detach(pthread_self())) { /* Detach thread */ perror2("pthread_detach", err); exit(1); printf("i am thread %d and I was called with argument %d\n", pthread_self(), *(int *) argp); pthread_exit(null); main(){ pthread_t thr; int err, arg = 29; /*New Thread */ if (err = pthread_create(&thr,null,thread_f,(void *) &arg)){ perror2("pthread_create", err); exit(1); printf("i am original thread %d and I created thread %d\n", pthread_self(), thr); pthread_exit(null); Print detached thread 12

13 Run output I am thread and I was called with argument 29 I am original thread and I created thread mema@bowser> 13

14 Create n threads that wait for a random number of seconds and then terminate #include <stdio.h> #include <string.h> /* For strerror */ #include <stdlib.h> /* For exit */ #include <pthread.h> /* For threads */ #define perror2(s,e) fprintf(stderr, "%s: %s\n", s, strerror(e)) #define MAX_SLEEP 10 void *sleeping(void *arg) { int sl = (int) arg; printf("thread %ld sleeping %d seconds...\n", pthread_self(), sl); sleep(sl); /* Sleep a number of seconds */ printf("thread %ld waking up\n", pthread_self()); pthread_exit(null); main(int argc, char *argv[]){ int n, i, sl, err; pthread_t *tids; if (argc > 1) n = atoi(argv[1]); /* Make integer */ else exit(0); if (n > 50) { /* Avoid too many threads */ printf("number of threads should be no more than 50\n"); exit(0); if ((tids = malloc(n * sizeof(pthread_t))) == NULL) { perror("malloc"); exit(1); 14

15 srandom((unsigned int) time(null)); /* Initialize generator */ for (i=0 ; i<n ; i++) { /* Sleeping time 1..MAX_SLEEP */ sl = random() % MAX_SLEEP + 1; if (err = pthread_create(tids+i, NULL, sleeping, (void *) sl)) { /* Create a thread */ perror2("pthread_create", err); exit(1); for (i=0 ; i<n ; i++) { /* Wait for thread termination */ if (err = pthread_join(*(tids+i), NULL)) { perror2("pthread_join", err); exit(1); printf("all %d threads have terminated\n", n);

16 Sample output 12 thread sleeping 8 seconds... thread sleeping 3 seconds... thread sleeping 7 seconds... thread sleeping 1 seconds... thread sleeping 2 seconds... thread sleeping 2 seconds... thread sleeping 5 seconds... thread sleeping 8 seconds... thread sleeping 5 seconds... thread sleeping 4 seconds... thread sleeping 2 seconds... thread sleeping 8 seconds... thread waking up thread waking up thread waking up thread waking up thread waking up thread waking up thread waking up thread waking up thread waking up thread waking up thread waking up thread waking up all 12 threads have terminated mema@bowser> 16

17 Going from a single-threaded program to multi-threading #include <stdio.h> #definenum 5 void print_mesg(char *); int main(){ print_mesg("hello"); print_mesg("world\n"); void print_mesg(char *m){ int i; for (i=0; i<num; i++){ printf("%s", m); fflush(stdout); sleep(1); mema@bowser>./print_single hellohellohellohellohelloworld world world world world mema@bowser> 17

18 First attempt.. #include <stdio.h> #include <pthread.h> #define NUM 5 main() { pthread_t t1, t2; void *print_mesg(void *); pthread_create(&t1, NULL, print_mesg, (void *)"hello "); pthread_create(&t2, NULL, print_mesg, (void *)"world\n") pthread_join(t1, NULL); pthread_join(t2, NULL); void *print_mesg(void *m) { char *cp = (char *)m; int i; for (i=0;i<num; i++){ printf("%s", cp); fflush(stdout); sleep(2); return NULL; 18

19 Output of 4 runs mema@bowser>./multi_hello hello world hello world hello world hello world hello world mema@bowser>./multi_hello hello world world hello hello world hello world hello world mema@bowser>./multi_hello world hello world hello hello world hello world hello world mema@bowser>./multi_hello world hello hello world hello world world hello world hello mema@bowser>

20 Another Example: Synchronization attempt (via sleep() ) #include <stdio.h> #include <pthread.h> #define NUM 5 int counter=0; main(){ pthread_t t1; void *print_count(void *); int i; pthread_create(&t1, NULL, print_count, NULL); for(i=0; i<num; i++){ counter++; sleep(1); pthread_join(t1,null); void *print_count(void *m){ /* counter is a shared variable */ int i; for (i=0;i<num;i++){ printf("count = %d\n",counter); sleep(1); /*changing this to something else has an effect */ return NULL; 20

21 Output count = 0 count = 1 count = 2 count = 3 count = 4 mema@bowser>./incprint count = 1 count = 1 count = 3 count = 4 count = 5 mema@bowser>./incprint count = 1 count = 2 count = 3 count = 4 count = 5 mema@bowser>./incprint count = 1 count = 1 count = 3 count = 4 count = 5 mema@bowser> Changing the sleep(1) to sleep(0) within print_count() we get the following: mema@bowser>./incprint count = 0 count = 0 count = 0 count = 0 count = 0 mema@bowser> 21

22 Counting words from two distinct files #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <ctype.h> int total_words; int main(int ac, char *av[]){ pthread_t t1, t2; void *count_words(void *); if (ac!= 3 ) { printf("usage: %s file1 file2 \n", av[0]); exit(1); total_words=0; pthread_create(&t1, NULL, count_words, (void *)av[1]); pthread_create(&t2, NULL, count_words, (void *)av[2]); pthread_join(t1, NULL); pthread_join(t2, NULL); printf("main thread with ID: %ld reports %5d total words\n, pthread_self(), total_words); 22

23 void *count_words(void *f){ char *filename = (char *)f; FILE *fp; int c, prevc = '\0'; printf("in thread with ID: %ld counting words.. \n", pthread_self()); if ( (fp=fopen(filename,"r"))!= NULL ){ while ( ( c = getc(fp) )!= EOF ){ if (!isalnum(c) && isalnum(prevc) ) total_words++; prevc = c; fclose(fp); else perror(filename); return NULL;

24 Output wc file1 file file file total mema@bowser>./wordcount1 file1 file2 In thread with ID: counting words.. In thread with ID: counting words.. Main thread with ID: reports 8 total words mema@bowser>./wordcount1 file1 file2 In thread with ID: counting words.. In thread with ID: counting words.. Main thread with ID: reports 6 total words mema@bowser> 24

25 Concurrent Access Potential Problem: Thread1 Thread total_words++ total_words Race-condition: total_words might not have consistent value after executing the above two assignments. Never allow concurrent access to data without protection (when at least one access is write)!

26 υαδικοίσηµατοφορείς static pthread_mutex_t koko = PTHREAD_MUTEX_INITIALIZER Αρχικοποίηση ΠΑΝΤΑ ΑΚΡΙΒΩΣ 1 φορά 26

27 υαδικοίσηµατοφορείς (συν) Υπάρχει και pthread_mutex_trylock 27

28 υαδικοίσηµατοφορείς (συν) Function: int pthread_mutex_trylock (pthread_mutex_t *mutex); behaves identically to pthread_mutex_lock, except that it does not block the calling thread if the mutex is already locked by another thread. Instead, pthread_mutex_trylock returns immediately with the error code EBUSY If pthread_mutex_trylock returns the error code EINVAL, the mutex was not initialized properly. 28

29 Counting (corretly) words in two files /* add all header files */ int total_words; pthread_mutex_t counter_lock = PTHREAD_MUTEX_INITIALIZER; int main(int ac, char *av[]) { pthread_t t1, t2; void *count_words(void *); if ( ac!= 3 ) { printf("usage: %s file1 file2 \n", av[0]); exit(1); total_words=0; pthread_create(&t1, NULL, count_words, (void *)av[1]); pthread_create(&t2, NULL, count_words, (void *)av[2]); pthread_join(t1, NULL); pthread_join(t2, NULL); printf("main thread wirth ID %ld reporting %5d total words\n", pthread_self(),total_words); 29

30 void *count_words(void *f){ char *filename = (char *)f; FILE *fp; int c, prevc = '\0'; if ( (fp=fopen(filename,"r"))!= NULL ){ while ( ( c = getc(fp) )!= EOF ){ if (!isalnum(c) && isalnum(prevc) ){ pthread_mutex_lock(&cou total_words++; pthread_mutex_unlock(&c prevc = c; fclose(fp); else perror(filename); return NULL;

31 Another program that counts words in two files correctly #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <ctype.h> #define EXIT_FAILURE 1 struct arg_set{ char *fname; int count; ; int main(int ac, char *av[]) { pthread_t t1, t2; struct arg_set args1, args2; void *count_words(void *); if ( ac!= 3 ) { printf("usage: %s file1 file2 \n", av[0]); exit (EXIT_FAILURE); 31

32 args1.fname = av[1]; args1.count = 0; pthread_create(&t1, NULL, count_words, (void *) &args1); args2.fname = av[2]; args2.count = 0; pthread_create(&t2, NULL, count_words, (void *) &args2); pthread_join(t1, NULL); pthread_join(t2, NULL); printf("in file %-10s there are %5d words\n", av[1], args1.count); printf("in file %-10s there are %5d words\n", av[2], args2.count); printf("main thread %ld reporting %5d total words\n", pthread_self(), args1.count+args2.count);

33 void *count_words(void *a) { struct arg_set *args = a; FILE *fp; int c, prevc = '\0'; printf("working within Thread with ID %ld and counting\n",pthread_self()); if ( (fp=fopen(args->fname,"r"))!= NULL ){ while ( ( c = getc(fp) )!= EOF ){ if (!isalnum(c) && isalnum(prevc) ){ args->count++; prevc = c; fclose(fp); No mutex in this function! else perror(args->fname); return NULL; 33

34 \ /etc/dictionaries-common/words \ /etc/dictionaries-common/ispell-default Working within Thread with ID and counting Working within Thread with ID and counting In file /etc/dictionaries-common/words there are words In file /etc/dictionaries-common/ispell-default there are 3 words Main thread reporting total words mema@bowser>

35 ΠΡΟΣΟΧΗ ΣΤΑ ΠΑΡΑΚΑΤΩ: Η pthread_mutex_trylockεπιστρέφει EBUSY αν ο σηµατοφορέας είναι ήδη κλειδωµένος από άλλο νήµα Κάθε δυαδικός σηµατοφορέας πρέπει να αρχικοποιηθεί ΑΚΡΙΒΩΣ 1 φορά Η pthread_mutex_unlockνακαλείται ΜΟΝΟαπότονήµαπουέχεικλειδωµένο το δυαδικό σηµατοφορέα ΠΟΤΕναµηνκαλείτετη pthread_mutex_lock από το νήµα που έχει Η Η κλειδώσει το σηµατοφορέα (στο είδος σηµατοφορέων που αναφέραµε προκαλεί αδιέξοδο) Αν λάβετε σφάλµα EINVAL σε προσπάθεια κλειδώµατος, τότε δεν έχετε αρχικοποιήσει το σηµατοφορέα ΠΟΤΕ κλήση της pthread_mutex_destroy σε κλειδωµένο σηµατοφορέα (EBUSY) 35

36 Using: pthread_mutex_init, pthread_mutex_lock, pthread_mutex_unlock, pthread_mutex_destroy... pthread_mutex_t mtx; /* Mutex for synchronization */ char buf[25]; /* Message to communicate */ void *thread_f(void *); /* Forward declaration */ main() { pthread_t thr; int err; printf("main Thread %ld running \n",pthread_self()); pthread_mutex_init(&mtx, NULL); if (err = pthread_mutex_lock(&mtx)) { /* Lock mutex */ perror2("pthread_mutex_lock", err); exit(1); printf("thread %d: Locked the mutex\n", pthread_self()); /* New thread */ if (err = pthread_create(&thr, NULL, thread_f, NULL)) { perror2("pthread_create", err); exit(1); printf("thread %ld: Created thread %d\n", pthread_self(), thr); strcpy(buf, "This is a test message"); printf("thread %ld: Wrote message \"%s\" for thread %ld\n", pthread_self(), buf, thr); 36

37 if (err = pthread_mutex_unlock(&mtx)) { /* Unlock mutex */ perror2("pthread_mutex_unlock", err); exit(1); printf("thread %ld: Unlocked the mutex\n", pthread_self()); if (err = pthread_join(thr, NULL)) { /* Wait for thread */ perror2("pthread_join", err); exit(1); /* termination */ printf("exiting Threads %ld and %ld \n", pthread_self(), thr); if (err = pthread_mutex_destroy(&mtx)) { /* Destroy mutex */ perror2("pthread_mutex_destroy", err); exit(1); pthread_exit(null);

38 Shall block here void *thread_f(void *argp){ /* Thread function */ int err; printf("thread %ld: Just started\n", pthread_self()); printf("thread %ld: Trying to lock the mutex\n", pthread_self()) if (err = pthread_mutex_lock(&mtx)) { /* Lock mutex */ perror2("pthread_mutex_lock", err); exit(1); printf("thread %ld: Locked the mutex\n", pthread_self()); printf("thread %ld: Read message \"%s\"\n", pthread_self(), buf); if (err = pthread_mutex_unlock(&mtx)) { /* Unlock mutex */ perror2("pthread_mutex_unlock", err); exit(1); printf("thread %ld: Unlocked the mutex\n", pthread_self()); pthread_exit(null); 38

39 Main Thread running Thread : Locked the mutex Thread : Just started Thread : Trying to lock the mutex Thread : Created thread Thread : Wrote message "This is a test message" \ for thread Thread : Locked the mutex Thread : Read message "This is a test message" Thread : Unlocked the mutex Thread : Unlocked the mutex Exiting Threads and mema@bowser>

40 Main Thread running Thread : Locked the mutex Thread : Created thread Thread : Wrote message "This is a test message" for thread Thread : Unlocked the mutex Thread : Just started Thread : Trying to lock the mutex Thread : Locked the mutex Thread : Read message "This is a test message" Thread : Unlocked the mutex Exiting Threads and mema@linux01>

41 Sum the squares of n integers using m threads... #include <pthread.h> #define perror2(s, e) fprintf(stderr, "%s: %s\n", s, strerror(e)) #define LIMITUP 100 pthread_mutex_t mtx; /* Mutex for synchronization */ int n, nthr, mtxfl; /* Variables visible by thread function */ double sqsum; /* Sum of squares */ void *square_f(void *); /* Forward declaration */ main(int argc, char *argv[]){ int i, err; pthread_t *tids; if (argc > 3) { n = atoi(argv[1]); /* Last integer to be squared */ nthr = atoi(argv[2]); /* Number of threads */ mtxfl = atoi(argv[3]); /* with lock (1)? or without lock (0) */ else exit(0); if (nthr > LIMITUP) { /* Avoid too many threads */ printf("number of threads should be up to 100\n"); exit(0); if ((tids = malloc(nthr * sizeof(pthread_t))) == NULL) { perror("malloc"); exit(1); 41

42 sqsum = (double) 0.0; /* Initialize sum */ pthread_mutex_init(&mtx, NULL); /* Initialize mutex */ for (i=0 ; i<nthr ; i++) { if (err = pthread_create(tids+i, NULL, square_f, (void *) i)) { /* Create a thread */ perror2("pthread_create", err); exit(1); for (i=0 ; i<nthr ; i++) if (err = pthread_join(*(tids+i), NULL)) { /* Wait for thread termination */ perror2("pthread_join", err); exit(1);

43 if (!mtxfl) printf("without mutex\n"); else printf("with mutex\n"); printf("%2d threads: sum of squares up to %d is %12.9e\n", nthr,n,sqsum); sqsum = (double) 0.0; /* Compute sum with a single thread */ for (i=0 ; i<n ; i++) sqsum += (double) (i+1) * (double) (i+1); printf("single thread: sum of squares up to %d is %12.9e\n", n, sqsum); printf("formula based: sum of squares up to %d is %12.9e\n", n, ((double) n)*(((double) n)+1)*(2*((double) n)+1)/6); pthread_exit(null); void *square_f(void *argp){ /* Thread function */ int i, thri, err; thri = (int) argp; for (i=thri ; i<n ; i+=nthr) { if (mtxfl) /* Is mutex used? */ if (err = pthread_mutex_lock(&mtx)) { /* Lock mutex */ perror2("pthread_mutex_lock", err); exit(1); sqsum += (double) (i+1) * (double) (i+1); if (mtxfl) /* Is mutex used? */ if (err = pthread_mutex_unlock(&mtx)) { /*Unlock mutex */ perror2("pthread_mutex_unlock", err); exit(1); 43 pthread_exit(null);

44 Execution outcome With mutex 99 threads: sum of squares up to is e+20 Single thread: sum of squares up to is e+20 Formula based: sum of squares up to is e+20 mema@bowser>./sum_of_squares Without mutex 99 threads: sum of squares up to is e+20 Single thread: sum of squares up to is e+20 Formula based: sum of squares up to is e+20 44

45 Synchronization & Performance Two threads, A and B A reads data from net and places in buffer, B reads data from buffer and computes with it A: 1) Ανάγνωσηδεδοµένων 2) Κλείδωµα mutex 3) Τοποθέτηση στην ουρά 4) Ξεκλείδωµα mutex 5) Επιστροφή στο 1) Β: 1) Κλείδωµα mutex 2) Ιf buffer not empty, αφαίρεση δεδοµένων 3) Ξεκλείδωµα mutex 4) Επιστροφή στο 1) Αυτό δουλεύει µια χαρά. Βλέπετε κάποιο πιθανό πρόβληµα;

46 ΜεταβλητέςΣυνθήκης 46

47 Συνάρτηση pthread_cond_wait Σηµαντικό 47

48 Avoiding Lost Signals/Unpredictable Scheduling We want to avoid the following scenario: T1 unlocks mutex; Context switch; T2 locks mutex, checks condition, about to wait Context switch; T1 signals on condition variable; Context switch; T2 has not yet called pthread_cond_wait: SIGNAL LOST OS does not accumulate/store signals When signal occurs, OS checks for all processes waiting on that signal and wakes them up Must associate the condition being checked/signaled with a mutex

49 Συναρτήσεις: pthread_cond_signal, pthread_cond_broadcast, pthread_cond_destroy ή αριθµό σφάλµατος 49

50 ιαδικασίαχρήσης ΜεταβλητώνΣυνθήκης Χρήση ΕΝOΣ ΜΟΝΟ mutex µε κάθε µεταβλητή συνθήκης Απόκτηση mutex πριν ελέγξετε κάποια συνθήκη Χρήση πάντα του ίδιου mutex για αλλαγές των µεταβλητών στη συνθήκη Να κρατάτε το mutex για µικρό µόνο διάστηµα Απελευθέρωση στο τέλος µε pthread_mutex_unlock 50

51 Use of: pthread_cond_init, pthread_cond_wait, pthread_cond_signal, pthread_cond_destroy #include <stdio.h> #include <string.h> #include <stdlib.h> #include <pthread.h> #define perror2(s, e) fprintf(stderr, "%s: %s\n", s, strerror(e)) pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cvar; /* Condition variable */ char buf[25]; /* Message to communicate */ void *thread_f(void *); /* Forward declaration */ main(){ pthread_t thr; int err; /* Initialize condition variable */ pthread_cond_init(&cvar, NULL); if (err = pthread_mutex_lock(&mtx)) { /* Lock mutex */ perror2("pthread_mutex_lock", err); exit(1); printf("thread %d: Locked the mutex\n", pthread_self()); /* New thread */ if (err = pthread_create(&thr, NULL, thread_f, NULL)) { perror2("pthread_create", err); exit(1); printf("thread %d: Created thread %d\n", pthread_self(), thr); 51

52 printf("thread %d: Waiting for signal\n", pthread_self()); pthread_cond_wait(&cvar, &mtx); /* Wait for signal */ printf("thread %d: Woke up\n", pthread_self()); printf("thread %d: Read message \"%s\"\n", pthread_self(), buf); if (err = pthread_mutex_unlock(&mtx)) { /* Unlock mutex */ perror2("pthread_mutex_unlock", err); exit(1); printf("thread %d: Unlocked the mutex\n", pthread_self()); if (err = pthread_join(thr, NULL)) { /* Wait for thread */ perror2("pthread_join", err); exit(1); /* termination */ printf("thread %d: Thread %d exited\n", pthread_self(), thr); if (err = pthread_cond_destroy(&cvar)) { /* Destroy condition variable */ perror2("pthread_cond_destroy", err); exit(1); pthread_exit(null);

53 void *thread_f(void *argp){ /* Thread function */ int err; printf("thread %d: Just started\n", pthread_self()); printf("thread %d: Trying to lock the mutex\n", pthread_self()); if (err = pthread_mutex_lock(&mtx)) /* Lock mutex */ perror2("pthread_mutex_lock", err); exit(1); printf("thread %d: Locked the mutex\n", pthread_self()); strcpy(buf, "This is a test message"); printf("thread %d: Wrote message \"%s\"\n", pthread_self(), buf); pthread_cond_signal(&cvar); /* Awake other thread */ printf("thread %d: Sent signal\n", pthread_self()); if (err = pthread_mutex_unlock(&mtx)) { /* Unlock mutex */ perror2("pthread_mutex_unlock", err); exit(1); printf("thread %d: Unlocked the mutex\n", pthread_self()); pthread_exit(null); 53

54 Execution output Thread : Locked the mutex Thread : Just started Thread : Trying to lock the mutex Thread : Created thread Thread : Waiting for signal Thread : Locked the mutex Thread : Wrote message "This is a test message" Thread : Sent signal Thread : Unlocked the mutex Thread : Woke up Thread : Read message "This is a test message" Thread : Unlocked the mutex Thread : Thread exited mema@bowser> 54

55 Three threads increase the value of a global variable while a fourth thread suspends its operation until a maximum value is reached. #include <stdio.h> #include <stdlib.h> #include <pthread.h> #define perror2(s, e) fprintf(stderr, "%s: %s\n", s, strerror(e)) #define COUNT_PER_THREAD 8 /* Count increments by each thread * #define THRESHOLD 19 * Count value to wake up thread */ int count = 0; /* The counter */ int thread_ids[4] = {0, 1, 2, 3; /* My thread ids */ pthread_mutex_t mtx; /* mutex */ pthread_cond_t cv; /* the condition variable */ void *incr(void *argp){ int i, j, err, *id = argp; for (i=0 ; i<count_per_thread ; i++) { if (err = pthread_mutex_lock(&mtx)) { /* Lock mutex */ perror2("pthread_mutex_lock", err); exit(1); count++; /* Increment counter */ if (count == THRESHOLD) { /* Check for threshold */ pthread_cond_signal(&cv); /* Signal suspended thread */ printf("incr: thread %d, count = %d, threshold reached\n", *id,count); 55

56 printf("incr: thread %d, count = %d\n", *id, count); if (err = pthread_mutex_unlock(&mtx)) { /* Unlock mutex */ perror2("pthread_mutex_unlock", err); exit(1); for (j=0 ; j < ; j++); /* For threads to alternate */ pthread_exit(null); void *susp(void *argp){ int err, *id = argp; printf("susp: thread %d started\n", *id); if (err = pthread_mutex_lock(&mtx)) { /* Lock mutex */ perror2("pthread_mutex_lock", err); exit(1); while (count < THRESHOLD) { /* If threshold not reached */ pthread_cond_wait(&cv, &mtx); /* suspend */ printf("susp: thread %d, signal received\n", *id); if (err = pthread_mutex_unlock(&mtx)) { /* Unlock mutex */ perror2("pthread_mutex_unlock", err); exit(1); pthread_exit(null); Always use a while loop and re-check the condition after receiving signal and returning from pthread_cond_wait; Why? 56

57 main() { int i, err; pthread_t threads[4]; pthread_mutex_init(&mtx, NULL); /* Initialize mutex */ pthread_cond_init(&cv, NULL); /* and condition variable */ for (i=0 ; i<3 ; i++) if (err = pthread_create(&threads[i], NULL, incr, (void *) &thread_ids[i])) { /* Create threads 0, 1, 2 */ perror2("pthread_create", err); exit(1); if (err = pthread_create(&threads[3], NULL, susp, (void *) &thread_ids[3])) { /* Create thread 3 */ perror2("pthread_create", err); exit(1); for (i=0 ; i<4 ; i++) if (err = pthread_join(threads[i], NULL)) { perror2("pthread_join", err); exit(1); ; /* Wait for threads termination */ printf("main: all threads terminated\n"); /* Destroy mutex and condition variable */ if (err = pthread_mutex_destroy(&mtx)) { perror2("pthread_mutex_destroy", err); exit(1); if (err = pthread_cond_destroy(&cv)) { perror2("pthread_cond_destroy", err); exit(1); pthread_exit(null); 57

58 incr: thread 0, count = 1 incr: thread 1, count = 2 incr: thread 2, count = 3 susp: thread 3 started incr: thread 0, count = 4 incr: thread 2, count = 5 incr: thread 1, count = 6 incr: thread 1, count = 7 incr: thread 0, count = 8 incr: thread 2, count = 9 incr: thread 1, count = 10 incr: thread 0, count = 11 incr: thread 2, count = 12 incr: thread 1, count = 13 incr: thread 0, count = 14 incr: thread 2, count = 15 incr: thread 1, count = 16 incr: thread 0, count = 17 incr: thread 2, count = 18 incr: thread 0, count = 19, threshold reached incr: thread 0, count = 19 susp: thread 3, signal received incr: thread 2, count = 20 incr: thread 1, count = 21 incr: thread 0, count = 22 incr: thread 2, count = 23 incr: thread 1, count = 24 main: all threads terminated mema@bowser> 58

59 ΑσφάλειαΝηµάτων Πρόβληµα επειδή πολλά νήµατα µπορούν να καλέσουν συναρτήσεις που δεν είναι ασφαλείς Αποτέλεσµα πολλών συναρτήσεων συστήµατος όχι ασφαλές 59

60 ΑσφάλειαΝηµάτων Μπορείτε εύκολα να µετατρέψετε τις συναρτήσεις αυτές σε ασφαλείς µε χρήση mutexes 60

61 ΠαράδειγµαΠαραγωγού Καταναλωτή Παραγωγοί (Π) εισάγουν δεδοµένα σε καταχωρητή Καταναλωτές (Κ) διαβάζουν δεδοµένα από καταχωρητή Τι να αποφύγουµε? ΚναδιαβάσειαντικείµενοπουοΠδενέχει ολοκληρώσει την εισαγωγή του Κ αφαιρεί αντικείµενο που δεν υπάρχει Κ αφαιρεί αντικείµενο που έχει ήδη αφαιρεθεί Π προσθέτει αντικείµενο ενώ ο καταχωρητής δεν έχει χώρο Πγράφειπάνωσεαντικείµενοπουδενέχει αφαιρεθεί 61

62 Χρήση Κυκλικού Καταχωρητή Περιορισµένου Μεγέθους bufin: points at next available slot for storing item bufout: points at slot where next reader should read from 62

63 Προστασία µε υαδικούς Σηµατοφορείς #include <errno.h> #include <pthread.h> #include buffer.h static buffer_t buffer[bufsize]; static pthread_mutex_t bufferlock = PTHREAD_MUTEX_INITIALIZER; static int bufin = 0; static int bufout = 0; static int totalitems = 0; Πόσαυπάρχουνστο buffer. Χρειάζεται? int getitem(buffer_t *itemp) { /* remove item from buffer and put in *itemp */ int error; int erroritem = 0; if (error = pthread_mutex_lock(&bufferlock)) /* no mutex, give up */ return error; if (totalitems > 0) { /* buffer has something to remove */ *itemp = buffer[bufout]; bufout = (bufout + 1) % BUFSIZE; totalitems--; else erroritem = EAGAIN; if (error = pthread_mutex_unlock(&bufferlock)) return error; /* unlock error more serious than no item*/ return erroritem; Τι επιστρέφει αν δεν υπάρχουν δεδοµένα?

64 int putitem(buffer_t item) { /* insert item into buffer */ int error; int erroritem = 0; if (error = pthread_mutex_lock(&bufferlock)) /* no mutex, give up */ return error; if (totalitems < BUFSIZE) { /* buffer has room for another item */ buffer[bufin] = item; bufin = (bufin + 1) % BUFSIZE; totalitems++; else erroritem = EAGAIN; if (error = pthread_mutex_unlock(&bufferlock)) return error; /* unlock error more serious than no slot*/ return erroritem;

65 fetching items from the buffer The following piece of code attempts to retrieve 10 items from the buffer[8] ring... int error, i, item; for (i=0; i<10; i++){ while ( (error = getitem(&item)) && (error== EAGAIN)) ; if (error) break; printf("retrieved item %d: %d\n", i, item); Problem?? 1) busy waiting 2) producers might get blocked -- (readers might continuously grab lock first) Solution: Use condition variables 65

66 Προστασία µε Μεταβλητές Συνθήκης // from changed slightly #include <stdio.h> #include <pthread.h> #include <unistd.h> #define POOL_SIZE 6 typedef struct { int data[pool_size]; int start; int end; int count; pool_t; int num_of_items = 15; pthread_mutex_t mtx; pthread_cond_t cond_nonempty; pthread_cond_t cond_nonfull; pool_t pool; void initialize(pool_t * pool) { pool->start = 0; pool->end = -1; pool->count = 0; 66

67 void place(pool_t * pool, int data) { pthread_mutex_lock(&mtx); while (pool->count >= POOL_SIZE) { printf(">> Found Buffer Full \n"); pthread_cond_wait(&cond_nonfull, &mtx); pool->end = (pool->end + 1) % POOL_SIZE; pool->data[pool->end] = data; pool->count++; pthread_mutex_unlock(&mtx); int obtain(pool_t * pool) { int data = 0; pthread_mutex_lock(&mtx); while (pool->count <= 0) { printf(">> Found Buffer Empty \n"); pthread_cond_wait(&cond_nonempty, &mtx); data = pool->data[pool->start]; pool->start = (pool->start + 1) % POOL_SIZE; pool->count--; pthread_mutex_unlock(&mtx); return data; 67

68 void * producer(void * ptr) { while (num_of_items > 0) { place(&pool, num_of_items); printf("producer: %d\n", num_of_items); num_of_items--; pthread_cond_signal(&cond_nonempty); usleep(300000); pthread_exit(0); void * consumer(void * ptr) { while (num_of_items > 0 pool.count > 0) { printf("consumer: %d\n", obtain(&pool)); pthread_cond_signal(&cond_nonfull); usleep(500000); pthread_exit(0); 68

69 int main(){ pthread_t cons, prod; initialize(&pool); pthread_mutex_init(&mtx, 0); pthread_cond_init(&cond_nonempty, 0); pthread_cond_init(&cond_nonfull, 0); pthread_create(&cons, 0, consumer, 0); pthread_create(&prod, 0, producer, 0); pthread_join(prod, 0); pthread_join(cons, 0); pthread_cond_destroy(&cond_nonempty); pthread_cond_destroy(&cond_nonfull); pthread_mutex_destroy(&mtx); return 0;

70 >> Found Buffer Empty producer: 15 consumer: 15 producer: 14 consumer: 14 producer: 13 producer: 12 consumer: 13 producer: 11 consumer: 12 producer: 10 producer: 9 consumer: 11 producer: 8 producer: 7 consumer: 10 producer: 6 consumer: 9 producer: 5 producer: 4 consumer: 8 producer: 3 producer: 2 consumer: 7 producer: 1 consumer: 6 consumer: 5 consumer: 4 consumer: 3 consumer: 2 consumer: 1 mema@bowser> 70

71 >> Found Buffer Empty producer: 15 consumer: 15 producer: 14 producer: 13 producer: 12 producer: 11 producer: 10 producer: 9 >> Found Buffer Full consumer: 14 producer: 8 >> Found Buffer Full consumer: 13 producer: 7 >> Found Buffer Full consumer: 12 producer: 6 >> Found Buffer Full consumer: 11 producer: 5 >> Found Buffer Full consumer: 10 producer: 4 >> Found Buffer Full consumer: 9 producer: 3 Outcome - usleep(0) 71

72 >> Found Buffer Full consumer: 8 producer: 2 >> Found Buffer Full consumer: 7 producer: 1 consumer: 6 consumer: 5 consumer: 4 consumer: 3 consumer: 2 consumer: 1 mema@bowser> Outcome - usleep(0) (cont d)

73 Food for Thought Where was the cond signal performed in relation to mutex lock/unlock in this example? Exercise: think about whether this is OK with X producers, X consumers, X CPUs, for X >=1.

Topic 6: Threads. *Ευχαριστίες στους Τάκη Σταµατόπουλο, Αλέξη ελή, και Αντώνη ελιγιαννάκη

Topic 6: Threads. *Ευχαριστίες στους Τάκη Σταµατόπουλο, Αλέξη ελή, και Αντώνη ελιγιαννάκη Topic 6: Threads *Ευχαριστίες στους Τάκη Σταµατόπουλο, Αλέξη ελή, και Αντώνη ελιγιαννάκη Threads - Νήµατα Lightweight Processes (LWPs) Try to overcome penalties Offer a more efficient way to develop apps

Διαβάστε περισσότερα

Νήµατα. Πολύ σηµαντικό

Νήµατα. Πολύ σηµαντικό Νήµατα Πολύ σηµαντικό 1 Νήµατα (συν.) Σηµαντικό 2 Νήµατα vs ιεργασίες Νήµατα ιεργασίες Χώρος εδοµένων Περιγραφητές Αρχείων fork exit exec Σήµατα Κοινός. Ότι αλλάζει το 1 νήµα το βλέπουν/ αλλάζουν και τα

Διαβάστε περισσότερα

ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ. Διαδιεργασιακή Επικοινωνία Εργαστηριακές Ασκήσεις

ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ. Διαδιεργασιακή Επικοινωνία Εργαστηριακές Ασκήσεις ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ Διαδιεργασιακή Επικοινωνία Εργαστηριακές Ασκήσεις Υλικό από: Modern Operating Systems Laboratory Exercises, Shrivakan Mishra Σύνθεση Κ.Γ. Μαργαρίτης, Τμήμα Εφαρμοσμένης Πληροφορικής,

Διαβάστε περισσότερα

NIKOΛΑΟΣ ΝΤΙΡΛΗΣ 5ο ΦΡΟΝΤΙΣΤΗΡΙΟ ΑΙΘΟΥΣΑ Β4

NIKOΛΑΟΣ ΝΤΙΡΛΗΣ 5ο ΦΡΟΝΤΙΣΤΗΡΙΟ ΑΙΘΟΥΣΑ Β4 NIKOΛΑΟΣ ΝΤΙΡΛΗΣ 5ο ΦΡΟΝΤΙΣΤΗΡΙΟ ΑΙΘΟΥΣΑ Β4 1 Ένα thread έχει: ID, program counter, register set, stack Μοιράζεται με τα άλλα threads της ίδιας διεργασίας τον κώδικα, τα δεδομένα και τους άλλους πόρους

Διαβάστε περισσότερα

Τμήμα Μηχανικών Πληροφορικής Τ.Ε. Σχολή Τεχνολογικών Εφαρμογών Ακαδημαϊκό έτος

Τμήμα Μηχανικών Πληροφορικής Τ.Ε. Σχολή Τεχνολογικών Εφαρμογών Ακαδημαϊκό έτος Τμήμα Μηχανικών Πληροφορικής Τ.Ε. Σχολή Τεχνολογικών Εφαρμογών Ακαδημαϊκό έτος 2016-2017 ΤΕΙ Ηπείρου - Άρτα Κατανεμημένα και Παράλληλα Συστήματα (εργαστήριο) Παραδείγματα με pthreads Γκόγκος Χρήστος Παράδειγμα

Διαβάστε περισσότερα

ΕΘΝΙΚΟ ΚΑΙ ΚΑΠΟΔΙΣΤΡΙΑΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΑΘΗΝΩΝ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ & ΤΗΛΕΠΙΚΟΙΝΩΝΙΩΝ ΧΕΙΜΕΡΙΝΟ ΕΞΑΜΗΝΟ ΜΑΘΗΜΑ: ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ

ΕΘΝΙΚΟ ΚΑΙ ΚΑΠΟΔΙΣΤΡΙΑΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΑΘΗΝΩΝ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ & ΤΗΛΕΠΙΚΟΙΝΩΝΙΩΝ ΧΕΙΜΕΡΙΝΟ ΕΞΑΜΗΝΟ ΜΑΘΗΜΑ: ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ ΕΘΝΙΚΟ ΚΑΙ ΚΑΠΟΔΙΣΤΡΙΑΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΑΘΗΝΩΝ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ & ΤΗΛΕΠΙΚΟΙΝΩΝΙΩΝ ΧΕΙΜΕΡΙΝΟ ΕΞΑΜΗΝΟ ΜΑΘΗΜΑ: ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ ΔΙΑΧΕΙΡΙΣΗ ΑΔΙΕΞΟΔΩΝ (DEADLOCKS) Γενικά, για τη διαχείριση των αδιεξόδων

Διαβάστε περισσότερα

ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ. Διεργασίες και Νήματα Εργαστηριακές Ασκήσεις

ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ. Διεργασίες και Νήματα Εργαστηριακές Ασκήσεις ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ Διεργασίες και Νήματα Εργαστηριακές Ασκήσεις Υλικό από: Modern Operating Systems Laboratory Exercises, Shrivakan Mishra Σύνθεση Κ.Γ. Μαργαρίτης, Τμήμα Εφαρμοσμένης Πληροφορικής, Πανεπιστήμιο

Διαβάστε περισσότερα

Εργαστήριο 14. Συγχρονισμός Νημάτων (χρήση pthread_mutex_t, pthread_cond_t)

Εργαστήριο 14. Συγχρονισμός Νημάτων (χρήση pthread_mutex_t, pthread_cond_t) Εργαστήριο 14 Συγχρονισμός Νημάτων (χρήση pthread_mutex_t, pthread_cond_t) Να γράψετε πρόγραμμα που να δημιουργεί 1 νήμα Έτσι στο πρόγραμμα σας θα υπάρχουν 2 νήματα (το ένα νήμα είναι το αρχικό νήμα που

Διαβάστε περισσότερα

ΝΗΜΑΤΑ - ΕΡΓΑΣΤΗΡΙΟ 1 - ΣΗΜΕΙΩΣΕΙΣ

ΝΗΜΑΤΑ - ΕΡΓΑΣΤΗΡΙΟ 1 - ΣΗΜΕΙΩΣΕΙΣ ΕΘΝΙΚΟ ΚΑΙ ΚΑΠΟΔΙΣΤΡΙΑΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΑΘΗΝΩΝ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ & ΤΗΛΕΠΙΚΟΙΝΩΝΙΩΝ ΑΚΑΔΗΜΑΪΚΟ ΕΤΟΣ 2017-2018 ΧΕΙΜΕΡΙΝΟ ΕΞΑΜΗΝΟ ΜΑΘΗΜΑ: ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ Νήματα (Threads) ΝΗΜΑΤΑ - ΕΡΓΑΣΤΗΡΙΟ 1 - ΣΗΜΕΙΩΣΕΙΣ

Διαβάστε περισσότερα

HY150a Φροντιστήριο 3 24/11/2017

HY150a Φροντιστήριο 3 24/11/2017 HY150a Φροντιστήριο 3 24/11/2017 1 Assignment 3 Overview Το πρόγραμμα ζητείται να διαβάζει μια λίστα δεδομένων που περιγράφει τα διαθέσιμα τμήματα μνήμης (blocks) ενός ΗΥ. Το πρόγραμμα ζητείται να μεταφορτώνει

Διαβάστε περισσότερα

Παρουσίαση 5 ης Άσκησης:

Παρουσίαση 5 ης Άσκησης: Εθνικό Μετσόβιο Πολυτεχνείο Σχολή Ηλεκτρολόγων Μηχ. και Μηχανικών Υπολογιστών Εργαστήριο Υπολογιστικών Συστημάτων Παρουσίαση 5 ης Άσκησης: Θέματα Συγχρονισμού σε Σύγχρονα Πολυπύρηνα Συστήματα Ακ. Έτος

Διαβάστε περισσότερα

ΕΙΣΑΓΩΓΗ ΣΤΟN ΠΡΟΓΡΑΜΜΑΤΙΣΜΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΑΤΡΩΝ ΠΟΛΥΤΕΧΝΙΚΗ ΣΧΟΛΗ ΤΜΗΜΑ ΜΗΧΑΝΙΚΩΝ Η/Υ ΚΑΙ ΠΛΗΡΟΦΟΡΙΚΗΣ

ΕΙΣΑΓΩΓΗ ΣΤΟN ΠΡΟΓΡΑΜΜΑΤΙΣΜΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΑΤΡΩΝ ΠΟΛΥΤΕΧΝΙΚΗ ΣΧΟΛΗ ΤΜΗΜΑ ΜΗΧΑΝΙΚΩΝ Η/Υ ΚΑΙ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΙΣΑΓΩΓΗ ΣΤΟN ΠΡΟΓΡΑΜΜΑΤΙΣΜΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΑΤΡΩΝ ΠΟΛΥΤΕΧΝΙΚΗ ΣΧΟΛΗ ΤΜΗΜΑ ΜΗΧΑΝΙΚΩΝ Η/Υ ΚΑΙ ΠΛΗΡΟΦΟΡΙΚΗΣ Εμβέλεια Μεταβλητών Εμβέλεια = το τμήμα του προγράμματος στο οποίο έχει ισχύ ή είναι ορατή η μεταβλητή.

Διαβάστε περισσότερα

Παρουσίαση 5 ης Άσκησης:

Παρουσίαση 5 ης Άσκησης: Εθνικό Μετσόβιο Πολυτεχνείο Σχολή Ηλεκτρολόγων Μηχ. και Μηχανικών Υπολογιστών Εργαστήριο Υπολογιστικών Συστημάτων Παρουσίαση 5 ης Άσκησης: Θέματα Συγχρονισμού σε Σύγχρονα Πολυπύρηνα Συστήματα Ακ. Έτος

Διαβάστε περισσότερα

Λειτουργικά Συστήματα

Λειτουργικά Συστήματα Τμήμα Μηχανικών Πληροφορικής & Τηλεπικοινωνιών Λειτουργικά Συστήματα Ενότητα: Πολυνηματικός Προγραμματισμός Δρ. Μηνάς Δασυγένης mdasyg@ieee.org Εργαστήριο Ψηφιακών Συστημάτων και Αρχιτεκτονικής Υπολογιστών

Διαβάστε περισσότερα

ΣυγχρονισµόςσεΣυστήµατα ΠολλαπλώνΝηµάτων

ΣυγχρονισµόςσεΣυστήµατα ΠολλαπλώνΝηµάτων ΣυγχρονισµόςσεΣυστήµατα ΠολλαπλώνΝηµάτων Συστήµατα Παράλληλης Επεξεργασίας Εργαστήριο Υπολογιστικών Συστηµάτων ΕΜΠ Κορνήλιος Κούρτης kkourt@cslab.ece.ntua.gr p. 1 Περιβάλλον Πολλαπλών Νηµάτων Threads T0

Διαβάστε περισσότερα

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007 Οδηγίες: Να απαντηθούν όλες οι ερωτήσεις. Όλοι οι αριθμοί που αναφέρονται σε όλα τα ερωτήματα μικρότεροι του 10000 εκτός αν ορίζεται διαφορετικά στη διατύπωση του προβλήματος. Αν κάπου κάνετε κάποιες υποθέσεις

Διαβάστε περισσότερα

Εκφωνήσεις ασκήσεων εργαστηρίου 2 (pthreads)

Εκφωνήσεις ασκήσεων εργαστηρίου 2 (pthreads) Τμήμα Μηχανικών Πληροφορικής Τ.Ε. Σχολή Τεχνολογικών Εφαρμογών Ακαδημαϊκό έτος 2016-2017 ΤΕΙ Ηπείρου - Άρτα Κατανεμημένα και Παράλληλα Συστήματα (εργαστήριο) Γκόγκος Χρήστος Εκφωνήσεις ασκήσεων εργαστηρίου

Διαβάστε περισσότερα

Lab 1: C/C++ Pointers and time.h. Panayiotis Charalambous 1

Lab 1: C/C++ Pointers and time.h. Panayiotis Charalambous 1 Lab 1: C/C++ Pointers and time.h Panayiotis Charalambous 1 Send email to totis@cs.ucy.ac.cy Subject: EPL231-Registration Body: Surname Firstname ID Group A or B? Panayiotis Charalambous 2 Code Guidelines:

Διαβάστε περισσότερα

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007 Οδηγίες: Να απαντηθούν όλες οι ερωτήσεις. Αν κάπου κάνετε κάποιες υποθέσεις να αναφερθούν στη σχετική ερώτηση. Όλα τα αρχεία που αναφέρονται στα προβλήματα βρίσκονται στον ίδιο φάκελο με το εκτελέσιμο

Διαβάστε περισσότερα

Εργαστήριο 5 fork(), exec(), signals

Εργαστήριο 5 fork(), exec(), signals Εργαστήριο 5 fork(), exec(), signals Στο εργαστήριο θα μελετηθούν: Παραδείγματα χρήσης των συναρτήσεων fork και exec Συνάρτηση waitpid Συνάρτηση WIFEXITED Συνάρτηση WEXITSTATUS Παράδειγμα χρήσης σημάτων

Διαβάστε περισσότερα

Λειτουργικά Συστήματα

Λειτουργικά Συστήματα Τμήμα Μηχανικών Πληροφορικής & Τηλεπικοινωνιών Λειτουργικά Συστήματα Ενότητα: Πολυνηματικός Προγραμματισμός Δρ. Μηνάς Δασυγένης mdasyg@ieee.org Εργαστήριο Ψηφιακών Συστημάτων και Αρχιτεκτονικής Υπολογιστών

Διαβάστε περισσότερα

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής Να γραφεί πρόγραμμα το οποίο δέχεται ως είσοδο μια ακολουθία S από n (n 40) ακέραιους αριθμούς και επιστρέφει ως έξοδο δύο ακολουθίες από θετικούς ακέραιους

Διαβάστε περισσότερα

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016 Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Dynamic types, Lambda calculus machines Apr 21 22, 2016 1 Dynamic types and contracts (a) To make sure you understand the

Διαβάστε περισσότερα

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων Εξάμηνο 7 ο Procedures and Functions Stored procedures and functions are named blocks of code that enable you to group and organize a series of SQL and PL/SQL

Διαβάστε περισσότερα

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible. B-Trees Index files can become quite large for large main files Indices on index files are possible 3 rd -level index 2 nd -level index 1 st -level index Main file 1 The 1 st -level index consists of pairs

Διαβάστε περισσότερα

Συστήματα Παράλληλης και Κατανεμημένης Επεξεργασίας

Συστήματα Παράλληλης και Κατανεμημένης Επεξεργασίας Συστήματα Παράλληλης και Κατανεμημένης Επεξεργασίας Ενότητα: ΕΡΓΑΣΤΗΡΙΑΚΗ ΑΣΚΗΣΗ No:10 Δρ. Μηνάς Δασυγένης mdasyg@ieee.org Τμήμα Μηχανικών Πληροφορικής και Τηλεπικοινωνιών Εργαστήριο Ψηφιακών Συστημάτων

Διαβάστε περισσότερα

Πανεπιστήμιο Θεσσαλίας Τμήμα Πληροφορικής

Πανεπιστήμιο Θεσσαλίας Τμήμα Πληροφορικής Πανεπιστήμιο Θεσσαλίας Τμήμα Πληροφορικής ΕΥ311-Διαδικτυακός και Ταυτόχρονος Προγραμματισμός Εργαστήριο: Παραδείγματα δημιουργίας διεργασιών στο Linux Ένα πρόγραμμα (το στιγμιότυπο της εκτέλεσης του οποίου

Διαβάστε περισσότερα

Παράλληλη Επεξεργασία

Παράλληλη Επεξεργασία Παράλληλη Επεξεργασία Φροντιστήριο: Εισαγωγή στα Πολυεπεξεργαστικά Συστήματα Διερασίες και Νήματα σε Πολυεπεξεργαστικά Συστήματα Εργαστήριο Πληροφοριακών Συστημάτων Υψηλής Επίδοσης Parallel and Distributed

Διαβάστε περισσότερα

Lab 1: C/C++ Pointers and time.h. Panayiotis Charalambous 1

Lab 1: C/C++ Pointers and time.h. Panayiotis Charalambous 1 Lab 1: C/C++ Pointers and time.h Panayiotis Charalambous 1 Send email to totis@cs.ucy.ac.cy Subject: EPL231-Registration Body: Surname Firstname ID Group A or B? Panayiotis Charalambous 2 Code Guidelines:

Διαβάστε περισσότερα

Εργαστήριο ΔΙΕΡΓΑΣΙΕΣ - ΔΙΑΧΕΙΡΙΣΗ

Εργαστήριο ΔΙΕΡΓΑΣΙΕΣ - ΔΙΑΧΕΙΡΙΣΗ Εργαστήριο ΔΙΕΡΓΑΣΙΕΣ - ΔΙΑΧΕΙΡΙΣΗ Εισαγωγή Σκοπός τόσο αυτού του εργαστηρίου, όσο και των εργαστηρίων που ακολουθούν, είναι να γνωρίσουμε τους τρόπους δημιουργίας και διαχείρισης των διεργασιών (processes)

Διαβάστε περισσότερα

The Simply Typed Lambda Calculus

The Simply Typed Lambda Calculus Type Inference Instead of writing type annotations, can we use an algorithm to infer what the type annotations should be? That depends on the type system. For simple type systems the answer is yes, and

Διαβάστε περισσότερα

UNIX System Programming

UNIX System Programming UNIX System Programming Processes Objectives look at how to program UNIX processes fork( ), wait( ) Overview 1. What is a Process? 2. fork() 3. wait() 4. Process Data 1. What is a Process? A process is

Διαβάστε περισσότερα

ή α α POSIX Threads ( έ ος 1 ο )

ή α α POSIX Threads ( έ ος 1 ο ) ι ο ι ά σ ή α α ο ισ η ια ή ό η α # 3 : ισα ω ή σ α ή α α POSIX Threads ( έ ος 1 ο ) ή α: οφο ι ής η α ο ό ηση ο α ό αι ι ό ι ό έχ ι α α χθ ί σ α αίσια ο αι ι ού έ ο ο ι άσ ο α. ο έ ο «Α οι ά Α α η αϊ

Διαβάστε περισσότερα

Εθνικό Μετσόβιο Πολυτεχνείο Σχολή Ηλεκτρολόγων Μηχ. και Μηχανικών Υπολογιστών Εργαστήριο Υπολογιστικών Συστημάτων. Συγχρονισμός

Εθνικό Μετσόβιο Πολυτεχνείο Σχολή Ηλεκτρολόγων Μηχ. και Μηχανικών Υπολογιστών Εργαστήριο Υπολογιστικών Συστημάτων. Συγχρονισμός Εθνικό Μετσόβιο Πολυτεχνείο Σχολή Ηλεκτρολόγων Μηχ. και Μηχανικών Υπολογιστών Εργαστήριο Υπολογιστικών Συστημάτων 3 η Εργαστηριακή Άσκηση: Συγχρονισμός Λειτουργικά Συστήματα Υπολογιστών 7ο Εξάμηνο, 2016-2017

Διαβάστε περισσότερα

Διάλεξη Εισαγωγή στη Java, Μέρος Γ

Διάλεξη Εισαγωγή στη Java, Μέρος Γ Τμήμα Πληροφορικής και Τηλεπικοινωνιών Ανάπτυξη Λογισμικού για Δίκτυα και Τηλεπικοινωνίες Χειμερινό Εξάμηνο 2017-2018 Διάλεξη Εισαγωγή στη Java, Μέρος Γ Νήματα (Threads) στην Java Συγχρονισμός Producer-Consumer

Διαβάστε περισσότερα

Προγραμματισμός συστημάτων UNIX/POSIX. Διαδιεργασιακή επικοινωνία: αγωγοί (IPC inter-process communication: pipes)

Προγραμματισμός συστημάτων UNIX/POSIX. Διαδιεργασιακή επικοινωνία: αγωγοί (IPC inter-process communication: pipes) Προγραμματισμός συστημάτων UNIX/POSIX Διαδιεργασιακή επικοινωνία: αγωγοί (IPC inter-process communication: pipes) Επικοινωνία μεταξύ διεργασιών γονέα-παιδιού Κατά κάποιο τρόπο, θα δημιουργήσουμε ένα τύπο

Διαβάστε περισσότερα

Δημιουργία & Τερματισμός Διεργασιών. Προγραμματισμός II 1

Δημιουργία & Τερματισμός Διεργασιών. Προγραμματισμός II 1 Δημιουργία & Τερματισμός Διεργασιών Προγραμματισμός II 1 lalis@inf.uth.gr Δημιουργία νέας διεργασίας pid_t fork() Η fork δεν έχει παραμέτρους Δημιουργεί μια νέα διεργασία που είναι ένα αντίγραφο της διεργασίας

Διαβάστε περισσότερα

Approximation of distance between locations on earth given by latitude and longitude

Approximation of distance between locations on earth given by latitude and longitude Approximation of distance between locations on earth given by latitude and longitude Jan Behrens 2012-12-31 In this paper we shall provide a method to approximate distances between two points on earth

Διαβάστε περισσότερα

(C) 2010 Pearson Education, Inc. All rights reserved.

(C) 2010 Pearson Education, Inc. All rights reserved. Connectionless transmission with datagrams. Connection-oriented transmission is like the telephone system You dial and are given a connection to the telephone of fthe person with whom you wish to communicate.

Διαβάστε περισσότερα

Φροντιςτήριο. Linked-List

Φροντιςτήριο. Linked-List Φροντιςτήριο Linked-List 1 Linked List Μια linked list είναι μια ακολουθία από ςυνδεδεμένουσ κόμβουσ Κάθε κόμβοσ περιέχει τουλάχιςτον Μια πληροφορία (ή ένα struct) Δείκτη ςτον επόμενο κόμβο τησ λίςτασ

Διαβάστε περισσότερα

Εθνικό Μετσόβιο Πολυτεχνείο Σχολή Ηλεκτρολόγων Μηχ. και Μηχανικών Υπολογιστών Εργαστήριο Υπολογιστικών Συστημάτων. Συγχρονισμός

Εθνικό Μετσόβιο Πολυτεχνείο Σχολή Ηλεκτρολόγων Μηχ. και Μηχανικών Υπολογιστών Εργαστήριο Υπολογιστικών Συστημάτων. Συγχρονισμός Εθνικό Μετσόβιο Πολυτεχνείο Σχολή Ηλεκτρολόγων Μηχ. και Μηχανικών Υπολογιστών Εργαστήριο Υπολογιστικών Συστημάτων 3 η Εργαστηριακή Άσκηση: Συγχρονισμός Λειτουργικά Συστήματα Υπολογιστών 7ο Εξάμηνο, 2017-2018

Διαβάστε περισσότερα

Δημιουργία & Τερματισμός Διεργασιών. Προγραμματισμός II 1

Δημιουργία & Τερματισμός Διεργασιών. Προγραμματισμός II 1 Δημιουργία & Τερματισμός Διεργασιών Προγραμματισμός II 1 lalis@inf.uth.gr Δημιουργία νέας διεργασίας pid_t fork() Η fork δεν έχει παραμέτρους Δημιουργεί μια νέα διεργασία που είναι ένα αντίγραφο της διεργασίας

Διαβάστε περισσότερα

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006 Οδηγίες: Να απαντηθούν όλες οι ερωτήσεις. Ολοι οι αριθμοί που αναφέρονται σε όλα τα ερωτήματα είναι μικρότεροι το 1000 εκτός αν ορίζεται διαφορετικά στη διατύπωση του προβλήματος. Διάρκεια: 3,5 ώρες Καλή

Διαβάστε περισσότερα

Κατηγορίες Νηµάτων. Νήµατα Επιπέδου Πυρήνα. Νήµατα Επιπέδου Χρήστη. «Νήµατα Επιπέδου Χρήστη» Ε-85: Ειδικά Θέµατα Λογισµικού

Κατηγορίες Νηµάτων. Νήµατα Επιπέδου Πυρήνα. Νήµατα Επιπέδου Χρήστη. «Νήµατα Επιπέδου Χρήστη» Ε-85: Ειδικά Θέµατα Λογισµικού Ε-85: Ειδικά Θέµατα Λογισµικού Προγραµµατισµός Συστηµάτων Υψηλών Επιδόσεων Χειµερινό Εξάµηνο 2009-10 «Νήµατα Επιπέδου Χρήστη» Κατηγορίες Νηµάτων Υπάρχουν δύο κατηγορίες νηµάτων Νήµατα επιπέδου πυρήνα (kernel

Διαβάστε περισσότερα

C: Από τη Θεωρία στην Εφαρμογή

C: Από τη Θεωρία στην Εφαρμογή Δρ. Γ. Σ. Τσελίκης Δρ. Ν. Δ. Τσελίκας C: Από τη Θεωρία στην Εφαρμογή Ενδεικτικές Ασκήσεις από το Βιβλίο C: Από τη Θεωρία στην Εφαρμογή (Γ. Σ. Τσελίκης Ν. Δ. Τσελίκας) Ενδεικτικές Ασκήσεις του Βιβλίου Ε.Α.1

Διαβάστε περισσότερα

Εισαγωγή στον Προγραμματισμό

Εισαγωγή στον Προγραμματισμό Εισαγωγή στον Προγραμματισμό Συναρτήσεις Δημήτρης Μιχαήλ Τμήμα Πληροφορικής και Τηλεματικής Χαροκόπειο Πανεπιστήμιο Ακ. Έτος 2012-2013 Συναρτήσεις Ως τώρα γράφαμε όλα τα προγράμματα μας μέσα στην main..1

Διαβάστε περισσότερα

Instruction Execution Times

Instruction Execution Times 1 C Execution Times InThisAppendix... Introduction DL330 Execution Times DL330P Execution Times DL340 Execution Times C-2 Execution Times Introduction Data Registers This appendix contains several tables

Διαβάστε περισσότερα

Ανάπτυξη Μεγάλων Εφαρµογών στη Γλώσσα C (2)

Ανάπτυξη Μεγάλων Εφαρµογών στη Γλώσσα C (2) Ανάπτυξη Μεγάλων Εφαρµογών στη Γλώσσα C (2) Στην ενότητα αυτή θα µελετηθούν τα εξής επιµέρους θέµατα: Οργάνωση Προγράµµατος Header Files Μετάφραση και σύνδεση αρχείων προγράµµατος ΕΠΛ 132 Αρχές Προγραµµατισµού

Διαβάστε περισσότερα

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch: HOMEWORK 4 Problem a For the fast loading case, we want to derive the relationship between P zz and λ z. We know that the nominal stress is expressed as: P zz = ψ λ z where λ z = λ λ z. Therefore, applying

Διαβάστε περισσότερα

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011 Διάρκεια Διαγωνισμού: 3 ώρες Απαντήστε όλες τις ερωτήσεις Μέγιστο Βάρος (20 Μονάδες) Δίνεται ένα σύνολο από N σφαιρίδια τα οποία δεν έχουν όλα το ίδιο βάρος μεταξύ τους και ένα κουτί που αντέχει μέχρι

Διαβάστε περισσότερα

Section 8.3 Trigonometric Equations

Section 8.3 Trigonometric Equations 99 Section 8. Trigonometric Equations Objective 1: Solve Equations Involving One Trigonometric Function. In this section and the next, we will exple how to solving equations involving trigonometric functions.

Διαβάστε περισσότερα

Κατανεμημένα και Παράλληλα Συστήματα (εργαστήριο) Παραδείγματα με openmp

Κατανεμημένα και Παράλληλα Συστήματα (εργαστήριο) Παραδείγματα με openmp Τμήμα Μηχανικών Πληροφορικής Τ.Ε. Σχολή Τεχνολογικών Εφαρμογών Ακαδημαϊκό έτος 2016-2017 ΤΕΙ Ηπείρου - Άρτα Κατανεμημένα και Παράλληλα Συστήματα (εργαστήριο) Παραδείγματα με openmp Γκόγκος Χρήστος Παράδειγμα

Διαβάστε περισσότερα

ύο μηχανισμοί απαιτούνται: 1. Μία μέθοδος για τη δημιουργία διεργασιών

ύο μηχανισμοί απαιτούνται: 1. Μία μέθοδος για τη δημιουργία διεργασιών Υπολογισμός με βάση το πέρασμα μηνυμάτων Προγραμματισμός με πέρασμα μηνυμάτων ύο μηχανισμοί απαιτούνται: 1. Μία μέθοδος για τη δημιουργία διεργασιών που θα εκτελούνται σε διαφορετικούς υπολογιστές. 2.

Διαβάστε περισσότερα

Διάλεξη 13: Δομές Δεδομένων ΙΙ (Ταξινομημένες Λίστες)

Διάλεξη 13: Δομές Δεδομένων ΙΙ (Ταξινομημένες Λίστες) Τμήμα Πληροφορικής Πανεπιστήμιο Κύπρου ΕΠΛ132 Αρχές Προγραμματισμού II Διάλεξη 13: Δομές Δεδομένων ΙΙ (Ταξινομημένες Λίστες) Δημήτρης Ζεϊναλιπούρ http://www.cs.ucy.ac.cy/courses/epl132 13-1 Περιεχόμενο

Διαβάστε περισσότερα

Κεφάλαιο 3.5-3.6, 3.2: Συναρτήσεις II. ( ιάλεξη 12) ιδάσκων: ηµήτρης Ζεϊναλιπούρ

Κεφάλαιο 3.5-3.6, 3.2: Συναρτήσεις II. ( ιάλεξη 12) ιδάσκων: ηµήτρης Ζεϊναλιπούρ Κεφάλαιο 3.5-3.6, 3.2: Συναρτήσεις II ( ιάλεξη 12) ιδάσκων: ηµήτρης Ζεϊναλιπούρ 12-1 Ανασκόπηση οµής Προγράµµατος µε Συναρτήσεις #include 1 void PrintMessage (); Πρότυπο ( ήλωση) Συνάρτησης (

Διαβάστε περισσότερα

The challenges of non-stable predicates

The challenges of non-stable predicates The challenges of non-stable predicates Consider a non-stable predicate Φ encoding, say, a safety property. We want to determine whether Φ holds for our program. The challenges of non-stable predicates

Διαβάστε περισσότερα

Κεφάλαιο , 3.2: Συναρτήσεις II. (Διάλεξη 12)

Κεφάλαιο , 3.2: Συναρτήσεις II. (Διάλεξη 12) Κεφάλαιο 3.5-3.6, 3.2: Συναρτήσεις II (Διάλεξη 12) 12-1 Ανασκόπηση Δομής Προγράμματος με Συναρτήσεις 1 void PrintMessage (); Πρότυπο (Δήλωση) Συνάρτησης (Δηλώνουν τι επιπλέον συναρτήσεις θα χρησιμοποιήσουμε

Διαβάστε περισσότερα

Hancock. Ζωγραφάκης Ιωάννης Εξαρχάκος Νικόλαος. ΕΠΛ 428 Προγραμματισμός Συστημάτων

Hancock. Ζωγραφάκης Ιωάννης Εξαρχάκος Νικόλαος. ΕΠΛ 428 Προγραμματισμός Συστημάτων Hancock Ζωγραφάκης Ιωάννης Εξαρχάκος Νικόλαος Χ346339 Τ911778 ΕΠΛ 428 Προγραμματισμός Συστημάτων Ιστορική Αναδρομή Δημιουργήθηκε από την εταιρεία ΑΤ&Τ LAB Αφορμή δημιουργίας: Η ανάγκη για καθαρό και αποδοτικό

Διαβάστε περισσότερα

ιεργασίες και νήµατα Προγραµµατισµός ΙΙΙ 1 lalis@inf.uth.gr

ιεργασίες και νήµατα Προγραµµατισµός ΙΙΙ 1 lalis@inf.uth.gr ιεργασίες και νήµατα Προγραµµατισµός ΙΙΙ 1 lalis@inf.uth.gr Η έννοια της διεργασίας ιεργασία (process) είναι ο µηχανισµός εκτέλεσης ενός προγράµµατος σε ένα λειτουργικό σύστηµα. Η διεργασία είναι µια ενεργή

Διαβάστε περισσότερα

Block Ciphers Modes. Ramki Thurimella

Block Ciphers Modes. Ramki Thurimella Block Ciphers Modes Ramki Thurimella Only Encryption I.e. messages could be modified Should not assume that nonsensical messages do no harm Always must be combined with authentication 2 Padding Must be

Διαβάστε περισσότερα

Προγραµµατισµός Νηµάτων. Αρχικοποίηση µιας Φοράς pthread_once_t once_block = PTHREAD_ONCE_INIT; pthread_mutex_t mutex;

Προγραµµατισµός Νηµάτων. Αρχικοποίηση µιας Φοράς pthread_once_t once_block = PTHREAD_ONCE_INIT; pthread_mutex_t mutex; Ε-85: Ειδικά Θέµατα Λογισµικού Προγραµµατισµός Συστηµάτων Υψηλών Επιδόσεων Προγραµµατισµός Νηµάτων Χειµερινό Εξάµηνο 2009-10 «Επαναληπτικές Ασκήσεις» Παναγιώτης Χατζηδούκας (Π.Δ. 407/80) E-85: Ε.Θ.Λ: Προγραµµατισµός

Διαβάστε περισσότερα

Εισαγωγή στον Προγραμματισμό

Εισαγωγή στον Προγραμματισμό Εισαγωγή στον Προγραμματισμό Έλεγχος Δημήτρης Μιχαήλ Τμήμα Πληροφορικής και Τηλεματικής Χαροκόπειο Πανεπιστήμιο Ακ. Έτος 2012-2013 Σχεσιακοί Τελεστές και Ισότητας Ένα πρόγραμμα εκτός από αριθμητικές πράξεις

Διαβάστε περισσότερα

Ε-85: Ειδικά Θέµατα Λογισµικού

Ε-85: Ειδικά Θέµατα Λογισµικού Ε-85: Ειδικά Θέµατα Λογισµικού Προγραµµατισµός Συστηµάτων Υψηλών Επιδόσεων Χειµερινό Εξάµηνο 2009-10 «Επαναληπτικές Ασκήσεις» Παναγιώτης Χατζηδούκας (Π.Δ. 407/80) E-85: Ε.Θ.Λ: Προγραµµατισµός Συστηµάτων

Διαβάστε περισσότερα

Προγραμματισμός Υπολογιστών με C++

Προγραμματισμός Υπολογιστών με C++ Προγραμματισμός Υπολογιστών με C++ ( 2012-13 ) 20η διάλεξη Ίων Ανδρουτσόπουλος http://www.aueb.gr/users/ion/ 1 Τι θα ακούσετε σήμερα Υλοποίηση στοίβας σε C. 2 Αναπαράσταση στοίβας StackNode n1 value 10

Διαβάστε περισσότερα

Προσομοίωση BP με το Bizagi Modeler

Προσομοίωση BP με το Bizagi Modeler Προσομοίωση BP με το Bizagi Modeler Α. Τσαλγατίδου - Γ.-Δ. Κάπος Πρόγραμμα Μεταπτυχιακών Σπουδών Τεχνολογία Διοίκησης Επιχειρησιακών Διαδικασιών 2017-2018 BPMN Simulation with Bizagi Modeler: 4 Levels

Διαβάστε περισσότερα

Εισαγωγή στον Προγραμματισμό

Εισαγωγή στον Προγραμματισμό Εισαγωγή στον Προγραμματισμό Πίνακες Δημήτρης Μιχαήλ Τμήμα Πληροφορικής και Τηλεματικής Χαροκόπειο Πανεπιστήμιο Ακ. Έτος 2012-2013 Πίνακες Πολλές φορές θέλουμε να κρατήσουμε στην μνήμη πολλά αντικείμενα

Διαβάστε περισσότερα

Ι Αρχεία δεδομένων, μέρος δεύτερο: δυαδικά αρχεία ΙΙ Δομές δεδομένων (struct)

Ι Αρχεία δεδομένων, μέρος δεύτερο: δυαδικά αρχεία ΙΙ Δομές δεδομένων (struct) Ι Αρχεία δεδομένων, μέρος δεύτερο: δυαδικά αρχεία ΙΙ Δομές δεδομένων (struct) Αρχεία Το γενικό πλαίσιο: data stream (ρεύμα δεδομένων). stdin, stdout, stderr data stream ως προς τα δεδομένα βάσει προσπέλασης

Διαβάστε περισσότερα

Σε γενικές γραμμές, είναι καλή πρακτική να γράϕουμε προγράμματα C που αποτελούνται από πολλές και μικρές συναρτήσεις, παρά από λίγες και μεγάλες.

Σε γενικές γραμμές, είναι καλή πρακτική να γράϕουμε προγράμματα C που αποτελούνται από πολλές και μικρές συναρτήσεις, παρά από λίγες και μεγάλες. 58 Δομή ενός προγράμματος C Συναρτήσεις Μία συνάρτηση C είναι ένα αυτόνομο, πακεταρισμένο τμήμα προγράμματος που ϕέρει σε πέρας μία διαδικασία η οποία έχει σαϕείς προδιαγραϕές εισόδου και εξόδου και συγκεκριμένο

Διαβάστε περισσότερα

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade Για να ελέγξετε το λογισμικό που έχει τώρα η συσκευή κάντε κλικ Menu > Options > Device > About Device Versions. Στο πιο κάτω παράδειγμα η συσκευή έχει έκδοση λογισμικού 6.0.0.546 με πλατφόρμα 6.6.0.207.

Διαβάστε περισσότερα

2 Composition. Invertible Mappings

2 Composition. Invertible Mappings Arkansas Tech University MATH 4033: Elementary Modern Algebra Dr. Marcel B. Finan Composition. Invertible Mappings In this section we discuss two procedures for creating new mappings from old ones, namely,

Διαβάστε περισσότερα

derivation of the Laplacian from rectangular to spherical coordinates

derivation of the Laplacian from rectangular to spherical coordinates derivation of the Laplacian from rectangular to spherical coordinates swapnizzle 03-03- :5:43 We begin by recognizing the familiar conversion from rectangular to spherical coordinates (note that φ is used

Διαβάστε περισσότερα

Διάλεξη 14: Δομές Δεδομένων ΙΙI (Λίστες και Παραδείγματα)

Διάλεξη 14: Δομές Δεδομένων ΙΙI (Λίστες και Παραδείγματα) Τμήμα Πληροφορικής Πανεπιστήμιο Κύπρου ΕΠΛ132 Αρχές Προγραμματισμού II Διάλεξη 14: Δομές Δεδομένων ΙΙI (Λίστες και Παραδείγματα) Δημήτρης Ζεϊναλιπούρ http://www.cs.ucy.ac.cy/courses/epl132 14-1 Περιεχόμενο

Διαβάστε περισσότερα

ΕΡΓΑΣΤΗΡΙΟ 1 - ΣΗΜΕΙΩΣΕΙΣ

ΕΡΓΑΣΤΗΡΙΟ 1 - ΣΗΜΕΙΩΣΕΙΣ ΠΑΝΕΠΙΣΤΗΜΙΟ ΘΕΣΣΑΛΙΑΣ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΑΚΑΔΗΜΑΪΚΟ ΕΤΟΣ 2017-2018 ΧΕΙΜΕΡΙΝΟ ΕΞΑΜΗΝΟ ΜΑΘΗΜΑ: ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ Εισαγωγή ΕΡΓΑΣΤΗΡΙΟ 1 - ΣΗΜΕΙΩΣΕΙΣ Ένα πρόγραμμα σε C περιλαμβάνει μια ή περισσότερες συναρτήσεις

Διαβάστε περισσότερα

Περιγραφή και Έλεγχος ιεργασιών

Περιγραφή και Έλεγχος ιεργασιών Περιγραφή και Έλεγχος ιεργασιών Περίληψη ιεργασίες Πολυπρογραµµατισµός Καταστάσεις ιεργασιών Περιγραφή διεργασιών στο ΛΣ Έλεγχος διεργασιών Το ΛΣ Linux 1 ιεργασία (process) ιεργασία είναι κάθε πρόγραµµα

Διαβάστε περισσότερα

ΑΡΧΕΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΥ

ΑΡΧΕΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΥ ΑΡΧΕΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΥ Κεφάλαιο 15 Επιμέλεια: Βασίλης Παλιουράς, Αναπληρωτής Καθηγητής Ευάγγελος Δερματάς, Αναπληρωτής Καθηγητής Σταύρος Νούσιας, Βοηθός Ερευνητή Πολυτεχνική Σχολή Τμήμα Ηλεκτρολόγων Μηχανικών

Διαβάστε περισσότερα

Υπολογισμός - Εντολές Επανάληψης

Υπολογισμός - Εντολές Επανάληψης Προγραμματισμός Η/Υ Ι Υπολογισμός - Εντολές Επανάληψης ΕΛΕΥΘΕΡΙΟΣ ΚΟΣΜΑΣ ΕΑΡΙΝΟ ΕΞΑΜΗΝΟ 2018-2019 ΤΜΗΜΑ ΗΛΕΚΤΡΟΛΟΓΩΝ ΜΗΧΑΝΙΚΩΝ Τ.Ε. 1 Περίληψη Σήμερα... θα συνεχίσουμε τη συζήτησή μας για τα βασικά στοιχεία

Διαβάστε περισσότερα

Ντίρλης Νικόλαος- ΕΤΥ 2 ο Φροντιστήριο Παρασκευή, 18/10/2013 Β4. Λειτουργικά Συστήματα- Φροντιστήριο 2

Ντίρλης Νικόλαος- ΕΤΥ 2 ο Φροντιστήριο Παρασκευή, 18/10/2013 Β4. Λειτουργικά Συστήματα- Φροντιστήριο 2 Ντίρλης Νικόλαος- ΕΤΥ 2 ο Φροντιστήριο Παρασκευή, 18/10/2013 Β4 Φροντιστήριο 2 1 Λειτουργικό Σύστημα -> Multitasking Κάθε διεργασία μπορεί να ειδωθεί σαν μία δέσμη στοιχείων που διατηρούνται από τον πυρήνα

Διαβάστε περισσότερα

Παράλληλη Επεξεργασία

Παράλληλη Επεξεργασία Παράλληλη Επεξεργασία Φροντιστήριο: Νήματα & Συγχρονισμός Μεταβλητές κλειδιά Φράγματα Εργαστήριο Πληροφοριακών Συστημάτων Υψηλής Επίδοσης Parallel and Distributed Systems Group Συγχρονισμός μεταξύ νημάτων

Διαβάστε περισσότερα

Εισαγωγή στους Η/Υ. Γιώργος Δημητρίου. Μάθημα 3-4: Προγραμματισμός MIPS. Πανεπιστήμιο Θεσσαλίας - Τμήμα Πληροφορικής

Εισαγωγή στους Η/Υ. Γιώργος Δημητρίου. Μάθημα 3-4: Προγραμματισμός MIPS. Πανεπιστήμιο Θεσσαλίας - Τμήμα Πληροφορικής Γιώργος Δημητρίου Μάθημα 3-4: Προγραμματισμός MIPS Προγραμματισμός σε Συμβολική Γλώσσα Η συμβολική γλώσσα: δεν έχει τύπους, δεν έχει δηλώσεις μεταβλητών, δεν έχει δομές ελέγχου, δεν έχει εντολές βρόχων,

Διαβάστε περισσότερα

Σημειώσεις όγδοης εβδομάδας

Σημειώσεις όγδοης εβδομάδας Σημειώσεις όγδοης εβδομάδας Για να την δημιουργία σειριακών αρχείων, χρησιμοποιείται η fopen(filename, w ). Το αρχείο δημιουργείται στον ίδιο φάκελο που τρέχει το εκτελέσιμο πρόγραμμα. Το παρακάτω πρόγραμμα,

Διαβάστε περισσότερα

Μετατροπή χαρακτήρων ASCII σε ακέραιο αριθµό (atoi) & Άνοιγµα αρχείου µέσα από τo QtSPIM, διάβασµα, και αποθήκευση του περιεχοµένου του στη µνήµη

Μετατροπή χαρακτήρων ASCII σε ακέραιο αριθµό (atoi) & Άνοιγµα αρχείου µέσα από τo QtSPIM, διάβασµα, και αποθήκευση του περιεχοµένου του στη µνήµη Μετατροπή χαρακτήρων ASCII σε ακέραιο αριθµό (atoi) & Άνοιγµα αρχείου µέσα από τo QtSPIM, διάβασµα, και αποθήκευση του περιεχοµένου του στη µνήµη ( ιάλεξη 3) ιδάσκων: Γιώργος Ζάγγουλος Email: zaggoulos.george@ucy.ac.cy

Διαβάστε περισσότερα

Μεθόδων Επίλυσης Προβλημάτων

Μεθόδων Επίλυσης Προβλημάτων ΕΠΛ 032.3: 3: Προγραμματισμός Μεθόδων Επίλυσης Προβλημάτων Αχιλλέας Αχιλλέως, Τμήμα Πληροφορικής, Πανεπιστήμιο Κύπρου Email: achilleas@cs.ucy.ac.cy Κεφάλαιο 9 Συναρτήσεις Μέρος II Θέματα ιάλεξης Μη- ομημένος

Διαβάστε περισσότερα

υναµική έσµευση Μνήµης (συν.) ΕΠΛ 132 Αρχές Προγραµµατισµού ΙΙ 2 Εφαρµογή

υναµική έσµευση Μνήµης (συν.) ΕΠΛ 132 Αρχές Προγραµµατισµού ΙΙ 2 Εφαρµογή υναµική έσµευση Μνήµης (συν.) Στην ενότητα αυτή θα µελετηθούν: Μια εφαρµογή συνδεδεµένων λιστών ιπλά συνδεδεµένες Λίστες ΕΠΛ 132 Αρχές Προγραµµατισµού ΙΙ 1 Εφαρµογή Ζητούµενο: Πρόγραµµα που παίρνει σαν

Διαβάστε περισσότερα

Προγραμματισμός με Κοινόχρηστο Χώρο Διευθύνσεων 4

Προγραμματισμός με Κοινόχρηστο Χώρο Διευθύνσεων 4 Προγραμματισμός με Κοινόχρηστο Χώρο Διευθύνσεων 4 Με το κεφάλαιο αυτό, αλλάζουμε θεματολογία και μπαίνουμε στον χώρο του προγραμματισμού των παράλληλων συστημάτων. Σε αντίθεση με τους κλασικούς σειριακούς

Διαβάστε περισσότερα

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0. DESIGN OF MACHINERY SOLUTION MANUAL -7-1! PROBLEM -7 Statement: Design a double-dwell cam to move a follower from to 25 6, dwell for 12, fall 25 and dwell for the remader The total cycle must take 4 sec

Διαβάστε περισσότερα

Προγραμματισμός συστημάτων UNIX/POSIX. Διεργασίες (processes)

Προγραμματισμός συστημάτων UNIX/POSIX. Διεργασίες (processes) Προγραμματισμός συστημάτων UNIX/POSIX Διεργασίες (processes) Δομή αρχείου προγράμματος Πρόγραμμα (program) ονομάζεται το εκτελέσιμο αρχείο που βρίσκεται αποθηκευμένο στο δίσκο (π.χ. το a.out, ή το ls ή

Διαβάστε περισσότερα

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά.

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά. Διαστημικό εστιατόριο του (Μ)ΑστροΈκτορα Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά. Μόλις μια παρέα πελατών κάτσει σε ένα

Διαβάστε περισσότερα

Λειτουργικά Συστήματα

Λειτουργικά Συστήματα Δρ. Βασίλης Ταμπακάς Δρ. Ιωάννης Ε. Λιβιέρης Τμήμα Μηχανικών Πληροφορικής Τ.Ε Περιεχόμενα Περιεχόμενα... 1 1. Εισαγωγή, Θεωρητική Υποδομή Εργαστηριακής Άσκησης... 2 2. Εργαστηριακή υποδομή εργαστηριακής

Διαβάστε περισσότερα

ΕΡΓΑΣΤΗΡΙΟ 5 ΣΗΜΕΙΩΣΕΙΣ

ΕΡΓΑΣΤΗΡΙΟ 5 ΣΗΜΕΙΩΣΕΙΣ ΠΑΝΕΠΙΣΤΗΜΙΟ ΘΕΣΣΑΛΙΑΣ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΑΚΑΔΗΜΑΪΚΟ ΕΤΟΣ 2017-2018 ΧΕΙΜΕΡΙΝΟ ΕΞΑΜΗΝΟ ΜΑΘΗΜΑ: ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ Ουρές ΕΡΓΑΣΤΗΡΙΟ 5 ΣΗΜΕΙΩΣΕΙΣ Μια ουρά αποτελεί μια δομή δεδομένων στη λογική του First-in

Διαβάστε περισσότερα

ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ II. Υφαντόπουλος Νικόλαος Υποψήφιος Διδάκτορας Contact:

ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ II. Υφαντόπουλος Νικόλαος Υποψήφιος Διδάκτορας Contact: ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ II Υφαντόπουλος Νικόλαος Υποψήφιος Διδάκτορας Contact: nifantop@unipi.gr Συναρτήσεις (1/2) Στη C χρησιμοποιούμε συχνά τις συναρτήσεις (functions), οι οποίες είναι ρουτίνες που επαναλαμβάνονται

Διαβάστε περισσότερα

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ Ενότητα 12: Συνοπτική Παρουσίαση Ανάπτυξης Κώδικα με το Matlab Σαμαράς Νικόλαος Άδειες Χρήσης Το παρόν εκπαιδευτικό υλικό υπόκειται σε άδειες χρήσης Creative Commons.

Διαβάστε περισσότερα

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation Overview Transition Semantics Configurations and the transition relation Executions and computation Inference rules for small-step structural operational semantics for the simple imperative language Transition

Διαβάστε περισσότερα

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required) Phys460.nb 81 ψ n (t) is still the (same) eigenstate of H But for tdependent H. The answer is NO. 5.5.5. Solution for the tdependent Schrodinger s equation If we assume that at time t 0, the electron starts

Διαβάστε περισσότερα

Προγραμματισμός Επιπλέον στοιχεία της C++

Προγραμματισμός Επιπλέον στοιχεία της C++ Προγραμματισμός Επιπλέον στοιχεία της C++ Προγραμματισμός Πρόγραμμα σε Διαφορετικά Αρχεία Οργανώνουμε καλύτερα τον κώδικα Χρήσιμα σε μεγάλα προγράμματα Παράδειγμα (human tracking) linker header files pgmio.cpp

Διαβάστε περισσότερα

Math221: HW# 1 solutions

Math221: HW# 1 solutions Math: HW# solutions Andy Royston October, 5 7.5.7, 3 rd Ed. We have a n = b n = a = fxdx = xdx =, x cos nxdx = x sin nx n sin nxdx n = cos nx n = n n, x sin nxdx = x cos nx n + cos nxdx n cos n = + sin

Διαβάστε περισσότερα

Συστήματα Διαχείρισης Βάσεων Δεδομένων

Συστήματα Διαχείρισης Βάσεων Δεδομένων ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ Συστήματα Διαχείρισης Βάσεων Δεδομένων Φροντιστήριο 9: Transactions - part 1 Δημήτρης Πλεξουσάκης Τμήμα Επιστήμης Υπολογιστών Tutorial on Undo, Redo and Undo/Redo

Διαβάστε περισσότερα

Προγραμματισμός Ι. Δυναμική Διαχείριση Μνήμης. Δημήτρης Μιχαήλ. Ακ. Έτος 2011-2012. Τμήμα Πληροφορικής και Τηλεματικής Χαροκόπειο Πανεπιστήμιο

Προγραμματισμός Ι. Δυναμική Διαχείριση Μνήμης. Δημήτρης Μιχαήλ. Ακ. Έτος 2011-2012. Τμήμα Πληροφορικής και Τηλεματικής Χαροκόπειο Πανεπιστήμιο Προγραμματισμός Ι Δυναμική Διαχείριση Μνήμης Δημήτρης Μιχαήλ Τμήμα Πληροφορικής και Τηλεματικής Χαροκόπειο Πανεπιστήμιο Ακ. Έτος 2011-2012 Ανάγκη για Δυναμική Μνήμη Στατική Μνήμη Μέχρι τώρα χρησιμοποιούσαμε

Διαβάστε περισσότερα

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

Main source: Discrete-time systems and computer control by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1 Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1 A Brief History of Sampling Research 1915 - Edmund Taylor Whittaker (1873-1956) devised a

Διαβάστε περισσότερα

Εισαγωγή Βασικές εντολές Εκτέλεση βήµα-βήµα Εξέταση/Ανάθεση GDB-101. Νίκος Ντάρµος Τµήµα Πληροφορικής Πανεπιστήµιο Ιωαννίνων

Εισαγωγή Βασικές εντολές Εκτέλεση βήµα-βήµα Εξέταση/Ανάθεση GDB-101. Νίκος Ντάρµος Τµήµα Πληροφορικής Πανεπιστήµιο Ιωαννίνων Νίκος Ντάρµος Τµήµα Πληροφορικής Πανεπιστήµιο Ιωαννίνων Ιωάννινα, Μάιος 2010 Βασικές λειτουργίες ενός debugger: Εκτέλεση προγράµµατος ϐήµα-ϐήµα. Παρακολούθηση τιµών µεταβλητών. Εξέταση

Διαβάστε περισσότερα

Χρήση των POSIX Threads

Χρήση των POSIX Threads Ε-85: Ειδικά Θέµατα Λογισµικού Προγραµµατισµός Συστηµάτων Υψηλών Επιδόσεων Χειµερινό Εξάµηνο 2009-10 «Προγραµµατισµός Νηµάτων Προτύπου POSIX» Παναγιώτης Χατζηδούκας (Π.Δ. 407/80) Χρήση των POSIX Threads

Διαβάστε περισσότερα