Topic 3: Error Handling, Low-level I/O, Signals * K24: Systems Programming Instructor: Mema Roussopoulou

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

Download "Topic 3: Error Handling, Low-level I/O, Signals * K24: Systems Programming Instructor: Mema Roussopoulou"

Transcript

1 Topic 3: Error Handling, Low-level I/O, Signals * K24: Systems Programming Instructor: Mema Roussopoulou

2 Error Handling Murphy s Law Anything that can go wrong, will go wrong. Potential errors/mistakes have to be anticipated and corresponding corrective action (if possible) should be adopted. Instead of using an fprintf(), the call perror() could be used: void perror(char *estring) Prints out the string pointed to by estring denoting a specific kind of a mistake (choice of the programmer), plus a system-generated error string If we include the header file #include <errno.h>, the variable errno will have as its value an integer corresponding to the latest error that occurred. if (amt=read(fd, buf, numbyte)) == -1) then fprintf(stderr, read failed; errno= %d\n, errno);

3 C Program with Error Handling (errors_demo.c) # include < stdio.h > /* for fopen, printf */ # include < stdlib.h > /* for malloc */ # include < errno.h > /* for errno */ int main () { FILE *fp = NULL; char *p = NULL; int stat =0; fp = fopen ( "a_non_existent _file", "r" ); if ( fp == NULL ) { /* check for error */ printf ("errno = %d \n ", errno); perror ("fopen"); } p =( char *) malloc ( ) ; if ( p == NULL ) { /* check for error */ printf ( "errno = %d \n", errno); perror ( " malloc " ) ; } else { printf ( "Carry on \n"); } stat = unlink ( "/etc/motd" ); if ( stat == -1) { /* check for error */ printf ( "errno = %d\n", errno) ; perror ( " unlink ") ; } return (1) ; }

4 C Program with Error Handling (errors_demo.c) gcc errors_demo.c errno = 2 fopen : No such file or directory errno=12 malloc: Cannot allocate memory Carry on errno = 13 unlink : Permission denied mema@bowser>

5 Low-level Input/Output The stdio library enables the average user to carry out I/O without worrying about buffering and/or data conversion. The stdio is a user-friendly set of system calls. Low-level I/O functionality is required 1. when the amenities of stdio are not desirable (for whatever reason) in accessing files/devices, or 2. when interprocess communication occurs with the help of pipes/sockets. Το χαµηλότερο επίπεδο αλληλεπίδρασης µε το OS UΝΙΧ είναι οι κλήσεις συστήµατος. Είναι τα «σηµεία εισόδου» στον πυρήνα.

6 Low-level I/O (cont d) In low-level I/O, file descriptors that identify files, pipes, sockets and devices are small integers The above is in contrast to what happens in the stdio library where respective identifiers are pointers. Designated (fixed) file descriptors: 0 : standard input 1 : standard output 2 : standard error (for error diagnostics). The above file descriptors 0, 1, and 2 correspond to pointers to the stdin, sdtout, and stderr files of the stdio library. The file descriptors are inherited by any child process that the parent in question creates.

7 Low-level I/O (cont d) Ένας δείκτης FILE δείχνει σε µια δοµή που περιέχει µεταξύ άλλων πραγµάτων, τον περιγραφέα του αρχείου. Όταν το κέλυφος ξεκινάει ένα πρόγραµµα να τρέξει, το πρόγραµµα κληρονοµεί 3 ανοικτά αρχεία µε περιγραφείς αρχείων 0,1,2. Αν το πρόγραµµα ανοίξει οποιαδήποτε αλλά αρχεία, θα έχουν περιγραφείς 3,4, κλπ. 7

8 The open() system call int open(char *pathname, int flags [, mode_t mode]) The call opens or creates a file with absolute or relative pathname for reading/writing. flags designates the way (a number) with which the file can be accessed; values for flags may be constructed by a bitwiseinclusive OR of flags from the following set: O_RDONLY: open for reading only. O_WRONLY: open for writing only. O_RDWR: open for both reading and writing. O_APPEND: write at the end of the file. O_CREAT: create a file if it does not already exist. O_TRUNC: the size of the file will be truncated to 0 if the file exists. Returns a file descriptor on success or -1 on failure.

9 The open() system call required: #include <fnctl.h> defines all these (and more) flags. The non-mandatory mode parameter is an integer that designates the desired access primitives during the creation of a file (access rights not allowed from the umask are not allowed). open returns an integer that designates the file created and, in case of no success, it returns -1.

10 Παραδείγµατα χρήσης open int myfd; myfd = open( /home/mema/my.dat, O_RDONLY); mode_t fdmode = (S_IRUSR S_IWUSR S_IRGRP S_IROTH); if ((fd = open( info.dat, O_RDWR O_CREAT, fdmode)) == -1) perror( Failed to open info.dat ); S_IRUSR S_IWUSR S_IXUSR S_IRWXU S_IRGRP S_IWGRP S_IXGRP S_IRWXG S_IROTH S_IWOTH S_IXOTH S_IRWXO Ανάγνωση ιδιοκτήτη Γραφή ιδιοκτήτη Εκτέλεση ιδιοκτήτη Ανάγνωση, γραφή, εκτέλεση ιδιοκτήτη Ανάγνωση οµάδα Γραφή οµάδα Εκτέλεση οµάδα Ανάγνωση, γραφή, εκτέλεση οµάδα Ανάγνωση λοιποί Γραφή λοιποί Εκτέλεση λοιποί Ανάγνωση, γραφή, εκτέλεση λοιποί 10

11 # include < stdio.h > // to have access to printf () # include < stdlib.h > // to enable exit calls # include < fcntl.h > // to have access to flags def # define PERMS 0644 // set access p e r m i s s i o n s char *workfile ="mytest" ; main () { int filedes; if (( filedes = open (workfile, O_CREAT O_RDWR, PERMS ) ) == -1) { perror(" creating "); exit(1); } else { printf (" Managed to get to the file successfully \n" ); } exit (0) ; }

12 gcc createfile.c Managed to get to the file successfully ls -l total 20 -rwxr - xr - x 1 mema mema :50 a.out -rw -r --r -- 1 mema mema :49 createfile.c -rw -r --r -- 1 mema mema :50 mytest mema@bowser> cat > mytest This is a test mema@bowser>./a.out Managed to get to the file successfully mema@bowser> ls a.out createfile.c mytest mema@bowser> more mytest This is a test mema@bowser>

13 The creat() call The creat call is an alternative way to create a file (instead of using open()). int creat(char *pathname, mode_t mode); pathname is any Unix pathname giving the target location in which the file is to be created. mode helps set up the access rights. creat will always truncate an existing file before returning its file descriptor. filedes = creat ("/tmp/mr.txt", 0644) ; is equivalent to: filedes = open ("/tmp/mr.txt", O_WRONLY O_CREAT O_TRUNC, 0644) ;

14 Εντολή read Πότε διαβάζει λιγότερα από count bytes? Αν το αρχείο έχει λιγότερα bytes Αν διακοπεί από σήµα Αν διαβάζει από σωλήνωση/υποδοχή, διαβάζει όταν βρίσκει κάτι διαθέσιµο => απαιτεί while loop για διάβασµα όλων των χαρακτήρων 14

15 Παράδειγµα συνάρτησης read char buf[100]; ssize_t bytesread; bytesread = read(stdin_fileno, buf, 100); char *buf; ssize_t bytesread; bytesread = read(stdin_fileno, buf, 100); Τι θα συµβεί εδώ? Στα επόµενα παραδείγµατα, STDIN_FILENO=0, STDOUT_FILE=1, STDERR_FILE=2 15

16 Εντολές write, close Κάντε man στις εντολές read, write, close για τα include files. Συχνά το unistd.h 16

17 Παραδείγµατα εντολής write Ίσως διαβάσει < 1024 bytes Καµιά εγγύηση ότι θα γράψει bytesread bytes 17

18 Παράδειγµα χρήσης read, write, close #include <stdio.h> #include <stdlib.h> /* for exit */ #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> int main(){ int fd, bytes, bytes1, bytes2; char buf[50]; mode_t fdmode = S_IRUSR S_IWUSR; if ( ( fd=open("t", O_WRONLY O_CREAT, fdmode ) ) == -1 ){ perror("open"); exit(1); } bytes1 = write(fd, "First write. ", 13); printf("%d bytes were written. \n", bytes1); close(fd); if ( (fd=open("t", O_WRONLY O_APPEND)) == -1 ){ perror("open"); exit(1); } bytes2 = write(fd, "Second Write. \n", 14); printf("%d bytes were written. \n", bytes2); 18 close(fd);

19 Παράδειγµα χρήσης read, write, close if ( (fd=open("t", O_RDONLY)) == -1 ){ perror("open"); exit(1); } bytes=read(fd, buf, bytes1+bytes2); printf("%d bytes were read \n",bytes); close(fd); } buf[bytes]='\0'; printf("%s\n",buf); return 1; 19

20 Παράδειγµα χρήσης read, write, close 13 bytes were written. 14 bytes were written. 27 bytes were read First write. Second Write. ls -lt total 12 -rwxr-xr-x 1 mema mema 5777 Dec 29 07:30 read-write-close* -rw-r--r-- 1 mema mema 842 Dec 29 07:19 read-write-close.c -rw mema mema 41 Dec 29 07:35 t mema@bowser> 20

21 Calls: dup, dup2 (Duplicate file descriptors) int dup(int oldfd); finds the lowest numbered unused file descriptor and makes it refer to the same entity to which oldfd refers. int dup2(int oldfd, int newfd); frees newfd (if in use) and makes newfd refer to the same entity to which oldfd refers - note: 1. If oldfd is not a valid file descriptor, then the call fails, and newfd is not closed. 2. If oldfd is a valid file descriptor, and newfd has the same value as oldfd, then dup2() does nothing, and returns newfd. After a successful return from one of these system calls, the old and new file descriptors may be used interchangeably.

22 Παράδειγµα dup, dup2 #include <stdio.h> #include <stdlib.h> /* for exit */ #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> int main(){ int fd1, fd2, fd3; mode_t fdmode = S_IRUSR S_IWUSR S_IRGRP S_IROTH; if ( ( fd1=open("r", O_WRONLY O_CREAT O_TRUNC, fdmode ) ) == -1 ){ perror("open"); exit(1); } printf("fd1 = %d\n", fd1); write(fd1, "What ", 5); fd2=dup(fd1); printf("fd2 = %d\n", fd2); write(fd2, "time", 4); close(0); 22

23 Παράδειγµα dup, dup2 } fd3=dup(fd1); printf("fd3 = %d\n", fd3); write(fd3, " is it", 6); dup2(fd2, 2); write(2,"?\n",2); close(fd1); close(fd2); close(fd3); return 1; 23

24 Παράδειγµα dup, dup2 fd1 = 3 fd2 = 4 fd3 = 0 mema@bowser> ls -l r -rw-r--r-- 1 mema mema 17 Dec 29 07:58 r mema@bowser> more r What time is it? mema@bowser> 24

25 Γράψτε ένα πρόγραµµα που αντιγράφει ένα αρχείο στο τέλος ενός άλλου #include <stdio.h> #include <string.h> #include <stdlib.h> /* for exit */ #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> int main(int argc, char *argv[]){ int n, from, to; char buf[1024]; mode_t fdmode = S_IRUSR S_IWUSR S_IRGRP S_IROTH; if (argc!=3) { write(2,"usage: ", 7); write(2, argv[0], strlen(argv[0])); write(2," from-file to-file\n", 19); exit(1); } if ( ( from=open(argv[1], O_RDONLY)) < 0 ){ perror("open"); exit(1); } 25

26 Γράψτε ένα πρόγραµµα που αντιγράφει ένα αρχείο στο τέλος ενός άλλου if ( (to=open(argv[2], O_WRONLY O_CREAT O_APPEND, fdmode)) < 0 ){ perror("open"); exit(1); } while ( (n=read(from, buf, sizeof(buf))) > 0 ) write(to,buf,n); close(from); close(to); return 1; } 26

27 Παράδειγµα from-to more f1 This is a test. mema@bowser>./from-to f1 f2 mema@bowser> more f2 This is a test.

28 Πρόσβαση σε inodes Κλήση stat 28

29 Πρόσβαση σε inodes Κλήση stat (συν.) 29

30 Παράδειγµα stat #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/stat.h> int main(int argc, char *argv[]){ struct stat statbuf; if (stat(argv[1], &statbuf) == -1) perror("failed to get file status"); else printf("%s accessed: %s modified: %s", argv[1], ctime(&statbuf.st_atime), ctime(&statbuf.st_mtime)); return 1; } 30

31 Παράδειγµα stat Failed to get file status: Bad address f1 f1 accessed: Tue Dec 29 08:47: modified: Tue Dec 29 08:47:

32 Πρόσβαση σε περιεχόµενα καταλόγων 32

33 Συναρτήσεις opendir, readdir, closedir 33

34 Παράδειγµα (dir) opendir, readdir, closedir #include <stdio.h> #include <sys/types.h> #include <dirent.h> void do_ls(char dirname[]){ DIR *dir_ptr; struct dirent *direntp; if ( ( dir_ptr = opendir( dirname ) ) == NULL ) fprintf(stderr, "cannot open %s \n",dirname); else { while { ( ( direntp=readdir(dir_ptr) )!= NULL ) printf("%s\n", direntp->d_name) ; } closedir(dir_ptr); } } 34

35 Παράδειγµα (dir) opendir, readdir, closedir int main(int argc, char *argv[]) { } if (argc == 1 ) do_ls("."); else while ( --argc ){ printf("%s: \n", *++argv ) ; do_ls(*argv); } 35

36 Παράδειγµα (dir) opendir, readdir, closedir mydir.:... read-write-close.c dup.c read-write-close t dup r from-to.c from-to f1 f2 stat.c stat dir.c mydir dir 36

37 Παράδειγµα (dir) opendir, readdir, closedir mydir:... a b c d e f g mema@bowser> 37

38 Παράδειγµα- Πρόγραµµα (ls-l)µε συµπεριφορά ls -al #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <stdio.h> #include <stdlib.h> #include <string.h> char *modes[]={"---","--x","-w-","-wx","r--","r-x", "rw-","rwx"}; // 8 distinct modes void list(char *); void printout(char *); main(int argc, char *argv[]){ struct stat mybuf; if (argc<2) { list("."); exit(0);} 38

39 Παράδειγµα- Πρόγραµµα (ls-l)µε συµπεριφορά ls -al while(--argc){ if (stat(*++argv, &mybuf) < 0) { perror(*argv); continue;} if ((mybuf.st_mode & S_IFMT) == S_IFDIR ) list(*argv); // directory encountered else printout(*argv); // file encountered } } 39

40 Συνέχεια παραδείγµατος (ls-l) void list(char *name){ DIR *dp; struct dirent *dir; char *newname; if ((dp=opendir(name))== NULL ) {perror("opendir"); return;} while ((dir = readdir(dp))!= NULL ) { if (dir->d_ino == 0 ) continue; newname=(char *)malloc(strlen(name)+ strlen(dir->d_name)+2); strcpy(newname,name); strcat(newname,"/"); strcat(newname,dir->d_name); printout(newname); free(newname); newname=null; } closedir(dp); } 40

41 Συνέχεια παραδείγµατος void printout(char *name){ struct stat mybuf; char type, perms[10]; int i,j; stat(name, &mybuf); switch (mybuf.st_mode & S_IFMT){ case S_IFREG: type = '-'; break; case S_IFDIR: type = 'd'; break; default: type = '?'; break; } *perms='\0'; for(i=2; i>=0; i--){ j = (mybuf.st_mode >> (i*3)) & 07; strcat(perms,modes[j]); } printf("%c%s%3d %5d/%-5d %7d %.12s %s \n", type,perms,mybuf.st_nlink, mybuf.st_uid, mybuf.st_gid, mybuf.st_size, ctime(&mybuf.st_mtime)+4, name); } 41

42 Αποτέλεσµα mydir drwxr-xr-x / Apr 26 19:48 mydir/. drwxr-xr-x / Apr 28 00:09 mydir/.. -rw-r--r / Apr 26 19:48 mydir/a -rw-r--r / Apr 26 19:48 mydir/b -rw-r--r / Apr 26 19:48 mydir/c -rw-r--r / Apr 26 19:48 mydir/d drwxr-xr-x / Apr 27 22:20 mydir/e drwxr-xr-x / Apr 26 19:48 mydir/f drwxr-xr-x / Apr 26 19:48 mydir/g -rw-r--r / Apr 26 19:48 mydir/i -rw-r--r / Apr 26 19:48 mydir/j -rw-r--r / Apr 26 19:48 mydir/k mema@bowser> 42

43 mkdir and readdir int mkdir(char *path, int mode) Creates a new directory path with permissions mode (permissions not allowed by umask are not given) Analogous to open for files int rmdir(char *path) Removes the directory path, if it is empty Analogous to unlink for files

44 chmod, rename calls int chmod(char *path, mode_t mode) int fchmod(int fd, mode_t mode) Change the permissions (on files with path name or having an fd descriptor) according to what mode designates. On success, 0 is returned; otherwise -1 int rename(const char *oldpath, const char *newpath) Renames a file, moving it between directories (indicated with the help of oldpath and newpath) if required. On success, 0 is returned; otherwise -1

45 lseek call off t lseek(int filedes, off t offset, int startflag); lseek repositions the offset of the open file associated with filedes to the argument offset according to the directive startflag as follows: 1. SEEK SET: The offset is set to offset bytes; usual actual integer value = 0 2. SEEK CUR: The offset is set to its current location plus offset bytes; usual actual integer value = 1 3. SEEK END: The offset is set to the size of the file plus offset bytes. usual actual integer value = 2

46 lseek call off_t newposition;... newposition = lseek(fd, (off_t) -32, SEEK_END); Positions the read/write pointer 32 bytes BEFORE the end of the file. When used with read() and write() system calls, provides all tools necessary to do input and output randomly.

47 link and unlink int unlink(char *pathname) Deletes a name from the file system; if that name is the last link to a file and no other process has the file open, the file is deleted and its space is made available. int link(char *oldpath, char *newpath) It creates a new hard link to an existing file. If newpath exists, it will not be overwritten. The created link essentially connects the inode of the oldpath with the name of the newpath.

48 symlink and readlink calls int symlink(const char *oldpath, const char *newpath) Creates a symbolic link named newpath that contains the string oldpath. A symbolic link (or soft link) may point to an existing file or to a nonexistent one; the latter is known as a dangling link. On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ssize_t readlink (char *path, char *buf, size_t bufsiz) Places the contents of the symbolic link path (i.e., the string for the path that the link points to) in the buffer buf that has size bufsiz. On success, readlink returns the number of bytes placed in buf; otherwise, -1

49 Παράδειγµα link #include <stdio.h> #include <unistd.h> if (link( /dira/name1, /dirb/name2 ) == -1) perror( Failed to make a new link in /dirb ); 49

50 Σήµατα Ειδοποίηση µέσω λογισµικού σε διεργασία ότι κάτι συνέβη Σφάλµα εκτέλεσης, core Από πληκτρολόγιο (Ctrl-C, Ctrl-Z) Μια διεργασία σε µία άλλη Εντολή kill κτλ 4 Επιλογές για κάθε σήµα: Αγνόησέ το Προκαθορισµένη δράση Ορισµός συνάρτησης (διαχειριστής σήµατος signal handler) για το πώς να αντιµετωπιστεί Μπλοκάρισέ το (possible with POSIX Reliable Signals) 50

51 SIGNAL NAME # DESCRIPTION; DEFAULT ACTION SIGABRT 6 Process abort; Implementation dependent SIGALRM 14 Alarm clock; (Μετρητής) Abnormal termination SIGBUS 7 Access undefined part of memory object; Implementation dependent SIGCHLD 17 Child terminated, stopped or continued; Ignore SIGCONT 18 Execution continued if stopped; Continue SIGFPE 8 Error in arithmetic operation as in division by zero; Implementation dependent SIGHUP 1 Hang-up (death) on controlling terminal (process); Abnormal termination SIGILL 4 Invalid hardware instruction; Implementation dependent

52 SIGNAL NAME # DESCRIPTION; DEFAULT ACTION SIGINT 2 Interactive attention signal (usually Ctrl-C); Abnormal termination SIGKILL 9 Terminated (cannot be caught or ignored); Abnormal termination SIGPIPE 13 Write on a pipe with no readers; Abnornal termination SIGQUIT 3 Interactive termination: core dump (usually Ctrl-\); Implementation dependent SIGSEGV 11 Invalid memory reference; Implementation dependent SIGSTOP 19 Execution stopped (cannot be caught or ignored); Stop SIGTERM 15 Termination; Abnormal termination SIGTSTP 20 Terminal stop (usually Ctrl-Z); Stop

53 SIGNAL NAME # DESCRIPTION; DEFAULT ACTION SIGTTIN 21 Background process attempting to read; Stop SIGTTOU 22 Background process attempting to write; Stop SIGUSR1 10 User-defined signal 1; Abnormal termination SIGUSR2 12 User-defined signal 2; Abnormal termination If any signal is used, the header file <signal.h> must be included.

54 Εντολή kill Εντολή κελύφους: kill [-signalname] processid kill -s signalname processid send a specific signal to process(es) kill -l (λίστα συµβολικών ονοµάτων για σήµατα -το γράµµα l εδώ, όχι το νούµερο) Παραδείγµατα: kill -USR kill -s USR kill

55 kill call #include <sys/types.h> #include <signal.h> int kill(pid_t pid, int sig) Signal sig is sent to process with pid Should the receiving and dispatching processes belong to the same user or the dispatching process is the superuser, the signal can be successfully sent. If sig is 0, then no signal is dispatched. On success (at least one signal was sent), zero is returned. On error, -1 is returned, and errno is set appropriately.

56 The signal system call #include<signal.h> void (*signal (int signum, void (*handler) (int))) (int) The signal() call installs a new signal handler for the signal with number signum. The signal handler is set to the handler which may be a user-specified function or either SIG_IGN or SIG_DFL. signal() returns the previous value of the signal handler, or SIG_ERR on error. This call is the traditional way of handling signals.

57 Παράδειγµαµε signal - handle signal #include <stdio.h> #include <signal.h> void f(int); int main(){ int i; signal(sigint, f); for(i=0;i<5;i++){ printf("hello\n"); sleep(1); } } void f(int signum){ /* no explicit call to function f */ printf("ouch!\n"); } 57

58 Παράδειγµαµε signal - handle signal mema@bowser>./handlesignal hello hello hello hello ^COUCH! hello mema@bowser> 58

59 Παράδειγµαµε signal ignore signal #include <stdio.h> #include <signal.h> int main(){ int i; If you change SIG_IGN to SIG_DFL, then default action is taken. signal(sigint, SIG_IGN); printf("you can't stop me here! \n"); while(1){ sleep(1); printf("haha \n"); } } /* use cntrl-\ to get rid of this process */ 59

60 Παράδειγµαµε signal ignore signal you can't stop me here! haha haha haha haha haha haha haha haha haha ^-\Quit 60

61 Συναρτήσεις raise, pause Εντολή int pause() Αναµονή διεργασίας µέχρι τη λήψη σήµατος που η δράση της είτε εκτελεί συνάρτηση χρήστη είτε τερµατίζει την διεργασία Πάντα επιστρέφει -1 #include <unistd.h> Εντολή int raise(int signalid) Στέλνει σήµα στην ίδια διεργασία!!! Σε επιτυχία 0. Αλλιώς <> 0 και θέτει το errno Πχ: if (raise(sigusr1)!= 0) perror( Failed to raise SIGUSR1 ); 61

62 The alarm call #include <unistd.h> unsigned int alarm(unsigned int count); alarm() delivers a SIGALRM to the invoking process in count seconds. The default signal handler prints a message and terminates the process. If count=0, previous alarm() call is canceled. Returns the number of seconds remaining until any previously scheduled alarm was due to be delivered; otherwise, 0.

63 The alarm call # include <stdio.h> # include <unistd.h> main () { alarm(3); /* schedule an alarm signal in 3sec */ printf("looping forever \n"); while (1); printf("this line should never be executed.\n"); } mema@bowser> date;./alarm_demo; date Mon Apr 12 21:20:41 EEST 2011 Looping forever Alarm clock Mon Apr 12 21:20:44 EEST 2011 mema@bowser>

64 Παράδειγµα: signal, alarm, pause #include <stdio.h> #include <signal.h> main(){ void wakeup(int); printf("about to sleep for 4 seconds \n"); signal(sigalrm, wakeup); alarm(4); pause(); printf("hola Amigo\n"); } void wakeup(int signum){ printf("alarm received from kernel\n"); } 64

65 Παράδειγµα: signal, alarm, pause about to sleep for 4 seconds Alarm received from kernel Hola Amigo mema@bowser> 65

66 Unreliable Signals a headache in older Unix int sig_int(); signal(sigint, sig_int); sig_int() { /* this is the point of possible problems */ signal(sigint, sig_int); } 1. After a signal has occurred but before the first line in sig_int has completed executing, another signal occurs. 2. The second signal would cause the default action which is to terminate the process. 3. Although the program may seem to work, we lose a signal in the process.

67 Unreliable Signals A process could NOT turn off (i.e., block) a signal to prevent the signal from interrupting it at a later time All process could do was to ignore the signal (with a trick) Below, intent is to have program wait until signal has occurred before continuing work int flag = 0; main() { int handler();... signal(sigint, handler);... while(flag == 0) { /* potential problem here*/ pause();... } handler() { signal(sigint, handler); flag = 1; }

68 Unreliable Signals Under regular circumstances the process would pause until it received a SIGINT and then continue on to other actions (after the while statement) as the predicate would disqualify. Problem: signal occurs after test (flag =0), but before call to pause process could sleep forever (if no other signals are generated) Signal is lost! Code NOT correct, yet works most of the time

69 Unreliable Signal-ing #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <signal.h> void foohandler(int); int flag=0; int main(){ int lpid=0; printf("the process ID of this program is %d \n",getpid()); lpid=getpid(); signal(sigint, foohandler); while (flag==0){ kill(lpid, SIGINT); pause(); }} void foohandler(int signum){ /* no explicit call to foohandler */ signal(sigint, foohandler); /* re-establish handler for next time */ flag=1; }

70 Unreliable Signal-ing Running the program, we get into the pause without noticing first signal got into the handler: The process ID of this program is 3245 The (first) signal seems to be lost Even though handler is invoked on first signal and flag gets set on the first signal, program is unaware of this because its check occurred before first signal is sent Forcing a second interrupt with control-c, we terminate the program: mema@bowser>./signal-examplea The process ID of this program is 3245 ^Cmema@bowser> Signal Sets provide a (POSIX) reliable way of dealing with signals

71 POSIX Signals -- first, some definitions When signal occurs, we say signal is generated Delivered means signal has been handled (default action, ignore, user-defined handler) Between generation and delivery a signal is pending If another signal of same type is generated, the delivery of the new signal is unspecified (implementation-specific) A thread can keep signal in pending state by blocking them Signal mask: the set of all blocked signals (for a particular thread) With POSIX (reliable) signals, when in a signal handler, the signal type is temporarily added to the mask so that another signal of same type doesn t get delivered.

72 POSIX Signal Sets Signal sets are defined using the type sigset_t Sets are large enough to hold a representation of all signals in the system We may indicate interest in specific signals by empty-ing a set and then adding signals or by using a full set and then by selectively deleting certain signals

73 POSIX Signal Sets Initialization of signals happens through: - int sigemptyset(sigset t *set); - int sigfillset(sigset t *set); Manipulation of signal sets happens via - int sigaddset(sigset *set, int signo); - int sigdelset(sigset *set, int signo); Membership in a signal set: - int sigismember(sigset t *set, int signo)

74 Example: creating different signal sets # include <signal.h> sigset_t mask1, mask2 ; sigempty (&mask1 ); // create an empty mask... sigaddset (&mask1, SIGINT ); // add signal SIGINT sigaddset (&mask1, SIGQUIT ); //add signal SIGQUIT... sigfillset (& mask2 ); // create a full mask... // remove signal SIGCHLD sigdelset (&mask2, SIGCHLD ); mask1 is created entirely empty mask2 is created entirely full mask2 is created entirely full.

75 sigaction() call Once a set has been defined, we can define a specific method to handle a signal using sigaction(). int sigaction(int signo, const struct sigaction *act, struct sigaction *oldact); When oldact is non-null, on return, points to old signal handling action (old sigaction structure) The sigaction structure is: struct sigaction { void (*sa_handler)(int); // action to be taken sigset t sa_mask; // additional signals to be // blocked during the handling // of the signal }; int sa_flags; // flags controlling handler // invocation void (*sa_sigaction)(int, siginfo_t *, void *); // pointer to a signal handler for // real-time signals

76 The sigaction structure sa_handler field: identifies the action to be taken when the signal signo is received (previous slide) 1. SIG_DFL: restores the system s default action 2. SIG_IGN: ignores the signal 3. The address of a function which takes an int as argument. The function will be executed when a signal of type signo is received and the value of signo is passed as parameter. Control is passed to function as soon as signal is received and when function returns, control is passed back to the point at which the process was interrupted. sa_mask field: the signals specified here will be blocked during the execution of the sa_handler.

77 The sigaction structure sa_flags field: used to modify the behavior of signo the originally specified signal. 1. A signal s action is reset to SIG_DFL on return from the handler by sa_flags=sa_resethand 2. Extra information will be passed to signal handler, if sa_flags=sig_info. Here, sa_handler is redundant and the final field sa_sigaction is used. Good idea to either use sa_handler or sa_sigaction. NOT both!

78 Use of sigaction # include < stdio.h > # include < stdlib.h > # include < signal.h > void catchinterrupt (int signo ){ printf("\ ncatching : signo =%d\n",signo ); printf(" Catching : returning \n"); } main (){ static struct sigaction act ; act.sa_handler = catchinterrupt ; sigfillset (&( act.sa_mask )); sigaction (SIGINT, &act, NULL ); printf(" sleep call #1\ n"); sleep (1) ; printf(" sleep call #2\ n"); sleep (1) ; printf(" sleep call #3\ n"); sleep (1) ; printf(" sleep call #4\ n"); sleep (1) ; printf(" Exiting \n"); exit (0) ; }

79 Regardless of where the program is interrupted, it resumes execution and carries on sleep call #1 sleep call #2 ^C Catching : signo =2 Catching : returning sleep call #3 ^C Catching : signo =2 Catching : returning sleep call #4 ^C Catching : signo =2 Catching : returning Exiting

80 Another execution: Regardless of where the program is interrupted, it resumes execution and carries on sleep call #1 sleep call #2 ^C Catching : signo =2 Catching : returning sleep call #3 sleep call #4 Exiting mema@bowser>

81 Changing the Behavior of program in interrupt # include < stdio.h > # include < stdlib.h > # include < signal.h > main (){ static struct sigaction act ; act.sa_handler = SIG_IGN ; // the handler is set to IGNORE sigfillset (&( act.sa_mask )); sigaction (SIGINT, &act, NULL ); // control -c sigaction (SIGTSTP, &act, NULL ); // control z printf(" sleep call #1\ n"); sleep (1) ; printf(" sleep call #2\ n"); sleep (1) ; printf(" sleep call #3\ n"); sleep (1) ; act.sa_handler = SIG_DFL ; // reestablish DEFAULT behavior sigaction (SIGINT, &act, NULL ); // default for control c printf(" sleep call #4\ n"); sleep (1) ; printf(" sleep call #5\ n"); sleep (1) ; printf(" sleep call #6\ n"); sleep (1) ; sigaction (SIGTSTP, &act, NULL ); // default for control -z printf(" Exiting \n"); exit (0) ; }

82 sleep call #1 ^Csleep call #2 ^Z^Csleep call #3 sleep call #4 sleep call #5 ^Zsleep call #6 Exiting sleep call #1 sleep call #2 sleep call #3 sleep call #4 sleep call #5 ^C sleep call #1 ^Csleep call #2 ^C^Z^Zsleep call #3 ^Z^Zsleep call #4 ^Z^Zsleep call #5 ^Z^Zsleep call #6 ^ZExiting

83 Restoring a previous action # include < stdio.h > # include < stdlib.h > # include < signal.h > main (){ static struct sigaction act, oldact; printf(" Saving the default way of handling the control =c\n"); sigaction (SIGINT, NULL, &oldact); printf(" sleep call #1\ n"); sleep (4) ; printf("changing (Ignoring) the way of handling \n"); act.sa_handler = SIG_IGN ; // the handler is set to IGNORE sigfillset(&( act.sa_mask )); sigaction(sigint, &act, NULL ); printf(" sleep call #2\ n"); sleep (4) ; printf("reestablishing old way of handling control-c\n"); sigaction(sigint, &oldact, NULL ); printf(" sleep call #3\ n"); sleep (4) ; printf(" Exiting \n"); exit (0) ; }

84 Saving the default way of handling the control =c sleep call #1 ^C Saving the default way of handling the control =c sleep call #1 Changing (Ignoring ) the way of handling sleep call #2 ^C^C^C^C^CRestablishing old way of handling control-c sleep call #3 ^C mema@bowser>

85 Blocking Signals Occasionally, a program wants to block all together (rather than ignore) incoming signals - for instance, when updating a data segment in a database. int sigprocmask(int how, const sigset t *set, sigset_t *oldset) how indicates what specific action sigprocmask should take: 1. SIG_BLOCK: set of blocked signals is the union of the current set and the set argument. 2. SIG_UNBLOCK: signals in set are removed from the current set of blocked signals. 3. SIG_SETMASK: group of blocked signals is set to set If oldset is non-null, the previous value of signal mask is stored in oldset. If set is NULL, the signal mask is unchanged and current value of mask is returned in oldset (if it is not NULL);

86 Example with sigprocmask() # include <stdio.h> # include <stdlib.h> # include <signal.h> main (){ sigset_t set1, set2 ; sigfillset (&set1 ); // completely full set sigfillset (&set2 ); sigdelset (&set2, SIGINT); sigdelset (&set2, SIGTSTP ); // a full set minus INT & TSTP printf(" This is simple code... \n"); sleep (5) ; // block everything here! sigprocmask ( SIG_SETMASK, &set1, NULL ); printf(" This is CRITICAL code... \n"); sleep (10) ; // unblock (allow) all but INT & TSTP sigprocmask ( SIG_UNBLOCK, &set2, NULL ); printf(" This is less CRITICAL code... \n"); sleep (5) ; // unblock (allow) all signals in set1 sigprocmask ( SIG_UNBLOCK, &set1, NULL ); printf("all signals are welcome!\n"); exit (0) ; }

87 This is simple code... ^C This is simple code... This is CRITICAL code... ^Z This is less CRITICAL code... Suspended fg./signal-sigprocmask All signals are welcome! This is simple code... This is CRITICAL code... ^C This is less CRITICAL code...

88 This is simple code... This is CRITICAL code... ^Z^C This is less CRITICAL code... fg bash : fg: current : no such job mema@bowser>./signal-sigprocmask This is simple code... This is CRITICAL code... ^Z^C^Z^C^Z^C^Z This is less CRITICAL code... ^\ Quit mema@bowser> fg bash : fg: current : no such job mema@bowser>./signal-sigprocmask This is simple code... This is CRITICAL code... This is less CRITICAL code... All signals are welcome! mema@bowser>

89 What signals to handle? If the program must do some cleanup before terminating, must handle: SIGHUP SIGINT SIGTERM Professional programs try to catch and handle as many signals as possible to enable Cleanup Error recording in log Display of error message Internal error #78: contact technical support is BETTER THAN Bus error: core dump Make signal handler a short function that returns quickly Better to raise a flag and have main program check that flag occasionally (see Rochkind for more) flag should be of type: volatile sig_atomic_t

Παράδειγµα χρήσης perror, errno (πρόγραµµα errors_demo.c)

Παράδειγµα χρήσης perror, errno (πρόγραµµα errors_demo.c) Χειρισµός Λαθών 1 Παράδειγµα χρήσης perror, errno (πρόγραµµα errors_demo.c) 2 Είσοδος/Έξοδος Χαµηλού Επιπέδου 3 Είσοδος/Έξοδος Χαµηλού Επιπέδου (συν.) Αυτό αργότερα στο εξάµηνο 4 Κλήση συστήµατος open

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

Προγραμματισμός συστημάτων UNIX/POSIX. Σήματα (signals)

Προγραμματισμός συστημάτων UNIX/POSIX. Σήματα (signals) Προγραμματισμός συστημάτων UNIX/POSIX Σήματα (signals) Σήματα (signals) Τα σήματα είναι «διακοπές» λογισμικού (software interrupts) οι οποίες διακόπτουν την κανονική λειτουργία μίας διεργασίας. Προκαλούνται

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

Προγραμματισμός συστημάτων UNIX/POSIX. Ανακατευθύνσεις (redirections)

Προγραμματισμός συστημάτων UNIX/POSIX. Ανακατευθύνσεις (redirections) Προγραμματισμός συστημάτων UNIX/POSIX Ανακατευθύνσεις (redirections) Shell & ανακατεύθυνση εισόδου Κατά την εκτέλεση ενός προγράμματος, η είσοδος και η έξοδος ενός προγράμματος μπορούν να ανακατευθυνθούν

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

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

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

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

Προγραμματισμός συστημάτων UNIX/POSIX

Προγραμματισμός συστημάτων UNIX/POSIX Προγραμματισμός συστημάτων UNIX/POSIX Προχωρημένη διαδιεργασιακή επικοινωνία: επώνυμοι αγωγοί (FIFOs) ουρές μηνυμάτων (message queues) κοινόχρηστη μνήμη (shared memory) σήματα (signals) Ανάγκη Ότι είδαμε

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

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

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

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

Διαχείριση Διεργασιών και Διαδιεργασιακή Επικοινωνία

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

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

Δίκτυα Επικοινωνιών ΙΙ: Network Programming UDP Sockets, Signals

Δίκτυα Επικοινωνιών ΙΙ: Network Programming UDP Sockets, Signals Δίκτυα Επικοινωνιών ΙΙ: Network Programming UDP Sockets, Signals Δρ. Απόστολος Γκάμας Διδάσκων 407/80 gkamas@uop.gr Δίκτυα Επικοινωνιών ΙΙ Διαφάνεια 1 1 UDP vs TCP Το UDP είναι ένα connectionless, μη αξιόπιστο,

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

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

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

Διαχείριση Διεργασιών και Διαδιεργασιακή Επικοινωνία

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

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

File Management και I/O στο UNIX

File Management και I/O στο UNIX File Management και I/O στο UNIX Λειτουργικά Συστήματα Ντίρλης Νικόλαος- ΕΤΥ Τμήμα Μηχανικών Η/Υ και Πληροφορικής Πάτρας Συστήματα 2013-2014 1 Εισαγωγή Ένα από τα βασικά στοιχεία της επιστήμης της Πληροφορικής

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

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

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

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

Προγραμματισμός συστημάτων UNIX/POSIX

Προγραμματισμός συστημάτων UNIX/POSIX Προγραμματισμός συστημάτων UNIX/POSIX Προχωρημένη διαδιεργασιακή επικοινωνία: επώνυμοι αγωγοί (FIFOs) ουρές μηνυμάτων (message queues) κοινόχρηστη μνήμη (shared memory) Ανάγκη Ότι είδαμε μέχρι τώρα μπορεί

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(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.

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

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

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

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

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

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

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

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

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

Modbus basic setup notes for IO-Link AL1xxx Master Block

Modbus basic setup notes for IO-Link AL1xxx Master Block n Modbus has four tables/registers where data is stored along with their associated addresses. We will be using the holding registers from address 40001 to 49999 that are R/W 16 bit/word. Two tables that

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

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

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

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

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

Διάλεξη 12: Προχωρημένη Είσοδος/Έξοδος Χαμηλού Επιπέδου (Advanced Low-Level I/O) Κεφάλαιο 4 Stevens & Rago

Διάλεξη 12: Προχωρημένη Είσοδος/Έξοδος Χαμηλού Επιπέδου (Advanced Low-Level I/O) Κεφάλαιο 4 Stevens & Rago ΕΠΛ371 - Προγραμματισμός Συστημάτων Διάλεξη 12: Προχωρημένη Είσοδος/Έξοδος Χαμηλού Επιπέδου (Advanced Low-Level I/O) Κεφάλαιο 4 Stevens & Rago Δημήτρης Ζεϊναλιπούρ 12-1 Περιεχόμενο Διάλεξης Στην προηγούμενη

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

ΕΘΝΙΚΟ ΚΑΙ ΚΑΠΟΔΙΣΤΡΙΑΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΑΘΗΝΩΝ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ & ΤΗΛΕΠΙΚΟΙΝΩΝΙΩΝ ΜΑΘΗΜΑ: ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ ΣΗΜΕΙΩΣΕΙΣ. Αρχεία και Μεταδεδομένα

ΕΘΝΙΚΟ ΚΑΙ ΚΑΠΟΔΙΣΤΡΙΑΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΑΘΗΝΩΝ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ & ΤΗΛΕΠΙΚΟΙΝΩΝΙΩΝ ΜΑΘΗΜΑ: ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ ΣΗΜΕΙΩΣΕΙΣ. Αρχεία και Μεταδεδομένα ΕΘΝΙΚΟ ΚΑΙ ΚΑΠΟΔΙΣΤΡΙΑΚΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΑΘΗΝΩΝ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ & ΤΗΛΕΠΙΚΟΙΝΩΝΙΩΝ ΜΑΘΗΜΑ: ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ Αρχεία και Μεταδεδομένα ΣΗΜΕΙΩΣΕΙΣ Κάθε αρχείο χαρακτηρίζεται και αναφέρεται από ένα αριθμό

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

Εισαγωγή στο περιβάλλον προγραμματισμού του εργαστηρίου

Εισαγωγή στο περιβάλλον προγραμματισμού του εργαστηρίου 1 Εισαγωγή στο περιβάλλον προγραμματισμού του εργαστηρίου Λειτουργικά Συστήματα 7ο εξάμηνο ΣΗΜΜΥ ακ έτος 2015-2016 http://wwwcslabecentuagr/courses/os CSLab National Technical University of Athens Εργαστήριο

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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,

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

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

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

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

Homework 3 Solutions

Homework 3 Solutions Homework 3 Solutions Igor Yanovsky (Math 151A TA) Problem 1: Compute the absolute error and relative error in approximations of p by p. (Use calculator!) a) p π, p 22/7; b) p π, p 3.141. Solution: For

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

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

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

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

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

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

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

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

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

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

Κλείδωμα αρχείων (file locking) Προγραμματισμός II 1

Κλείδωμα αρχείων (file locking) Προγραμματισμός II 1 Κλείδωμα αρχείων (file locking) Προγραμματισμός II 1 lalis@inf.uth.gr Κλείδωμα αρχείων Οι διεργασίες που προσπελάζουν ένα αρχείο μέσω ξεχωριστών περιγραφέων, μπορούν να γράψουν / διαβάσουν τα περιεχόμενα

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

4 η ιάλεξη: Signals UDP Sockets

4 η ιάλεξη: Signals UDP Sockets Εργαστήριο ικτύων Υπολογιστών 4 η ιάλεξη: ικτυακός Προγραμματισμός Signals UDP Sockets TCP sockets και signals Όταν σε ένα TCP server κάνουμε fork (γεννάμε διεργασίες-παιδιά servers για να εξυπηρετήσουμε

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

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.

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

Εισαγωγή στο περιβάλλον προγραμματισμού του εργαστηρίου. Λειτουργικά Συστήματα Εργαστήριο Υπολογιστικών Συστημάτων ΕΜΠ

Εισαγωγή στο περιβάλλον προγραμματισμού του εργαστηρίου. Λειτουργικά Συστήματα Εργαστήριο Υπολογιστικών Συστημάτων ΕΜΠ Εισαγωγή στο περιβάλλον προγραμματισμού του εργαστηρίου Λειτουργικά Συστήματα Εργαστήριο Υπολογιστικών Συστημάτων ΕΜΠ Διαδικαστικά Λογαριασμοί (Accounts) Χρήστης: oslabxyy Αλλαγή password: yppasswd Μηχανήματα

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

EE512: Error Control Coding

EE512: Error Control Coding EE512: Error Control Coding Solution for Assignment on Finite Fields February 16, 2007 1. (a) Addition and Multiplication tables for GF (5) and GF (7) are shown in Tables 1 and 2. + 0 1 2 3 4 0 0 1 2 3

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

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

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

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

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

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

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

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

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

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

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS CHAPTER 5 SOLVING EQUATIONS BY ITERATIVE METHODS EXERCISE 104 Page 8 1. Find the positive root of the equation x + 3x 5 = 0, correct to 3 significant figures, using the method of bisection. Let f(x) =

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

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

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

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

TMA4115 Matematikk 3

TMA4115 Matematikk 3 TMA4115 Matematikk 3 Andrew Stacey Norges Teknisk-Naturvitenskapelige Universitet Trondheim Spring 2010 Lecture 12: Mathematics Marvellous Matrices Andrew Stacey Norges Teknisk-Naturvitenskapelige Universitet

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

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

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

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

the total number of electrons passing through the lamp.

the total number of electrons passing through the lamp. 1. A 12 V 36 W lamp is lit to normal brightness using a 12 V car battery of negligible internal resistance. The lamp is switched on for one hour (3600 s). For the time of 1 hour, calculate (i) the energy

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

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής 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.

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

Λύβας Χρήστος Αρχική επιµέλεια Πιτροπάκης Νικόλαος και Υφαντόπουλος Νικόλαος

Λύβας Χρήστος Αρχική επιµέλεια Πιτροπάκης Νικόλαος και Υφαντόπουλος Νικόλαος ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ IΙ Λύβας Χρήστος chrislibas@ssl-unipi.gr Αρχική επιµέλεια Πιτροπάκης Νικόλαος και Υφαντόπουλος Νικόλαος >_ FILE SYSTEM >_ ΔΙΚΑΙΩΜΑΤΑ >_ ΔΙΚΑΙΩΜΑΤΑ? >_ ΜΕΤΑΒΟΛΗ ΔΙΚΑΙΩΜΑΤΩΝ +- chmod

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

Every set of first-order formulas is equivalent to an independent set

Every set of first-order formulas is equivalent to an independent set Every set of first-order formulas is equivalent to an independent set May 6, 2008 Abstract A set of first-order formulas, whatever the cardinality of the set of symbols, is equivalent to an independent

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

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =? Teko Classes IITJEE/AIEEE Maths by SUHAAG SIR, Bhopal, Ph (0755) 3 00 000 www.tekoclasses.com ANSWERSHEET (TOPIC DIFFERENTIAL CALCULUS) COLLECTION # Question Type A.Single Correct Type Q. (A) Sol least

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

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

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

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

Διάλεξη 18η: Διαχείρηση Αρχείων

Διάλεξη 18η: Διαχείρηση Αρχείων Διάλεξη 18η: Διαχείρηση Αρχείων Τμήμα Επιστήμης Υπολογιστών, Πανεπιστήμιο Κρήτης Εισαγωγή στην Επιστήμη Υπολογιστών Πρατικάκης (CSD) Αρχεία CS100, 2015-2016 1 / 24 Η βιβλιοθήκη Εισόδου/Εξόδου Στο stdioh

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

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ - ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 133: ΑΝΤΙΚΕΙΜΕΝΟΣΤΡΕΦΗΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ - ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 133: ΑΝΤΙΚΕΙΜΕΝΟΣΤΡΕΦΗΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial Introduction Το Javadoc είναι ένα εργαλείο που παράγει αρχεία html (παρόμοιο με τις σελίδες στη διεύθυνση http://docs.oracle.com/javase/8/docs/api/index.html) από τα σχόλια

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

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

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

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

Σήματα (Signals) Προγραμματισμός II 1

Σήματα (Signals) Προγραμματισμός II 1 Σήματα (Signals) Προγραμματισμός II 1 lalis@inf.uth.gr Τι είναι ένα σήμα; Το σήμα είναι μια ειδοποίηση που στέλνεται στην διεργασία που εκτελεί ένα πρόγραμμα Μπορεί να προκύψει για διάφορους λόγους, π.χ.

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

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

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

Αγωγοί/Σωλήνες (Pipes) Προγραμματισμός II 1

Αγωγοί/Σωλήνες (Pipes) Προγραμματισμός II 1 Αγωγοί/Σωλήνες (Pipes) Προγραμματισμός II 1 lalis@inf.uth.gr Τι είναι ένας αγωγός; Μηχανισμός/συσκευή επικοινωνίας διεργασιών Μετάδοση μιας ροής από bytes (μονής κατεύθυνσης) First-in-first-out (FIFO):

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

Math 6 SL Probability Distributions Practice Test Mark Scheme

Math 6 SL Probability Distributions Practice Test Mark Scheme Math 6 SL Probability Distributions Practice Test Mark Scheme. (a) Note: Award A for vertical line to right of mean, A for shading to right of their vertical line. AA N (b) evidence of recognizing symmetry

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

Section 9.2 Polar Equations and Graphs

Section 9.2 Polar Equations and Graphs 180 Section 9. Polar Equations and Graphs In this section, we will be graphing polar equations on a polar grid. In the first few examples, we will write the polar equation in rectangular form to help identify

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

Σήματα (Signals) Προγραμματισμός II 1

Σήματα (Signals) Προγραμματισμός II 1 Σήματα (Signals) Προγραμματισμός II 1 lalis@inf.uth.gr Τι είναι ένα σήμα; Το σήμα είναι μια ειδοποίηση Μπορεί να προκύψει για διάφορους λόγους Π.χ., εξαίρεση αριθμητικής πράξης, τερματισμός διεργασίας

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

SOAP API. https://bulksmsn.gr. Table of Contents

SOAP API. https://bulksmsn.gr. Table of Contents SOAP API https://bulksmsn.gr Table of Contents Send SMS...2 Query SMS...3 Multiple Query SMS...4 Credits...5 Save Contact...5 Delete Contact...7 Delete Message...8 Email: sales@bulksmsn.gr, Τηλ: 211 850

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

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

6.1. Dirac Equation. Hamiltonian. Dirac Eq. 6.1. Dirac Equation Ref: M.Kaku, Quantum Field Theory, Oxford Univ Press (1993) η μν = η μν = diag(1, -1, -1, -1) p 0 = p 0 p = p i = -p i p μ p μ = p 0 p 0 + p i p i = E c 2 - p 2 = (m c) 2 H = c p 2

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

Διαδιεργασιακή επικοινωνία (inter-process communication IPC) Προγραμματισμός II 1

Διαδιεργασιακή επικοινωνία (inter-process communication IPC) Προγραμματισμός II 1 Διαδιεργασιακή επικοινωνία (inter-process communication IPC) Προγραμματισμός II 1 lalis@inf.uth.gr Συνεργασία ανάμεσα σε διεργασίες Για ασφάλεια/ανεξαρτησία, το ΛΣ εξασφαλίζει πλήρη απομόνωση ανάμεσα στις

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

CYTA Cloud Server Set Up Instructions

CYTA Cloud Server Set Up Instructions CYTA Cloud Server Set Up Instructions ΕΛΛΗΝΙΚΑ ENGLISH Initial Set-up Cloud Server To proceed with the initial setup of your Cloud Server first login to the Cyta CloudMarketPlace on https://cloudmarketplace.cyta.com.cy

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

Σήματα (Signals) Προγραμματισμός II 1

Σήματα (Signals) Προγραμματισμός II 1 Σήματα (Signals) Προγραμματισμός II 1 lalis@inf.uth.gr Τι είναι ένα σήμα; Το σήμα είναι μια ειδοποίηση που στέλνεται στην διεργασία που εκτελεί ένα πρόγραμμα Μπορεί να προκύψει για διάφορους λόγους, π.χ.

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

Statistical Inference I Locally most powerful tests

Statistical Inference I Locally most powerful tests Statistical Inference I Locally most powerful tests Shirsendu Mukherjee Department of Statistics, Asutosh College, Kolkata, India. shirsendu st@yahoo.co.in So far we have treated the testing of one-sided

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

Τµήµα Ηλεκτρολόγων Μηχανικών & Μηχανικών Υπολογιστών Σεπτέµβριος 2013

Τµήµα Ηλεκτρολόγων Μηχανικών & Μηχανικών Υπολογιστών Σεπτέµβριος 2013 Γράψτε όλες τις απαντήσεις σας σε αυτό το φυλλάδιο Οδηγίες για Α: Διαβάστε προσεκτικά όλες τις επιλογές σηµειώστε µε Χ (το πολύ) µια από αυτές. Μην επιλέγετε «στην τύχη» οι λανθασµένες απαντήσεις βαθµολογούνται

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

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

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

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

ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ ΔΙΕΡΓΑΣΙΕΣ

ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ ΔΙΕΡΓΑΣΙΕΣ ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ ΔΙΕΡΓΑΣΙΕΣ Πολυεπεξεργασία Διεργασία (process) Νήμα (thread) Εργασία (task/job) Διεργασίες Διεργασία είναι μια (συγκεκριμένη) εκτέλεση κάποιου προγράμματος για λογαριασμό κάποιου

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

Other Test Constructions: Likelihood Ratio & Bayes Tests

Other Test Constructions: Likelihood Ratio & Bayes Tests Other Test Constructions: Likelihood Ratio & Bayes Tests Side-Note: So far we have seen a few approaches for creating tests such as Neyman-Pearson Lemma ( most powerful tests of H 0 : θ = θ 0 vs H 1 :

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

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι She selects the option. Jenny starts with the al listing. This has employees listed within She drills down through the employee. The inferred ER sttricture relates this to the redcords in the databasee

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

Example Sheet 3 Solutions

Example Sheet 3 Solutions Example Sheet 3 Solutions. i Regular Sturm-Liouville. ii Singular Sturm-Liouville mixed boundary conditions. iii Not Sturm-Liouville ODE is not in Sturm-Liouville form. iv Regular Sturm-Liouville note

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

Assalamu `alaikum wr. wb.

Assalamu `alaikum wr. wb. LUMP SUM Assalamu `alaikum wr. wb. LUMP SUM Wassalamu alaikum wr. wb. Assalamu `alaikum wr. wb. LUMP SUM Wassalamu alaikum wr. wb. LUMP SUM Lump sum lump sum lump sum. lump sum fixed price lump sum lump

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

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω 0 1 2 3 4 5 6 ω ω + 1 ω + 2 ω + 3 ω + 4 ω2 ω2 + 1 ω2 + 2 ω2 + 3 ω3 ω3 + 1 ω3 + 2 ω4 ω4 + 1 ω5 ω 2 ω 2 + 1 ω 2 + 2 ω 2 + ω ω 2 + ω + 1 ω 2 + ω2 ω 2 2 ω 2 2 + 1 ω 2 2 + ω ω 2 3 ω 3 ω 3 + 1 ω 3 + ω ω 3 +

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

Δίκτυα Δακτυλίου. Token Ring - Polling

Δίκτυα Δακτυλίου. Token Ring - Polling Δίκτυα Δακτυλίου Token Ring - Polling Όλοι οι κόμβοι είναι τοποθετημένοι σε ένα δακτύλιο. Εκπέμπει μόνο ο κόμβος ο οποίος έχει τη σκυτάλη (token). The token consists of a number of octets in a specific

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

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

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

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

ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ II. Υφαντόπουλος Νικόλαος Υποψήφιος Διδάκτορας Contact: ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ II Υφαντόπουλος Νικόλαος Υποψήφιος Διδάκτορας Contact: nifantop@unipi.gr Περιεχόμενα ενότητας Διεργασίες Κλήσεις δημιουργίας και τερματισμού διεργασιών Επικοινωνία διεργασιών μέσω

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

Concrete Mathematics Exercises from 30 September 2016

Concrete Mathematics Exercises from 30 September 2016 Concrete Mathematics Exercises from 30 September 2016 Silvio Capobianco Exercise 1.7 Let H(n) = J(n + 1) J(n). Equation (1.8) tells us that H(2n) = 2, and H(2n+1) = J(2n+2) J(2n+1) = (2J(n+1) 1) (2J(n)+1)

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

ιαδικτυακές Εφαρµογές

ιαδικτυακές Εφαρµογές ιαδικτυακές Εφαρµογές µε Java2 Στοιχεία ικτυακής Επικοινωνίας Όροι IP address 32bit αριθµός που χρησιµοποιείται από το Internet Protocol για την παράδοση δεδοµένων στο σωστό υπολογιστή στο δίκτυο. Port

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

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

Εισαγωγή στα Λειτουργικά Συστήματα Εισαγωγή στα Λειτουργικά Συστήματα S E T Δ Ι Α Φ Α Ν Ε Ι Ω Ν 1 3 S H E L L S C R I P T S : T E S T, I F Α Ν Τ Ω Ν Η ς Σ Ι Δ Η Ρ Ο Π Ο Υ Λ Ο ς Διεργασίες: Γονείς και Παιδιά Κάθε διεργασία κάνοντας exit

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

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8  questions or comments to Dan Fetter 1 Eon : Fall 8 Suggested Solutions to Problem Set 8 Email questions or omments to Dan Fetter Problem. Let X be a salar with density f(x, θ) (θx + θ) [ x ] with θ. (a) Find the most powerful level α test

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

Capacitors - Capacitance, Charge and Potential Difference

Capacitors - Capacitance, Charge and Potential Difference Capacitors - Capacitance, Charge and Potential Difference Capacitors store electric charge. This ability to store electric charge is known as capacitance. A simple capacitor consists of 2 parallel metal

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

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Partial Differential Equations in Biology The boundary element method. March 26, 2013 The boundary element method March 26, 203 Introduction and notation The problem: u = f in D R d u = ϕ in Γ D u n = g on Γ N, where D = Γ D Γ N, Γ D Γ N = (possibly, Γ D = [Neumann problem] or Γ N = [Dirichlet

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

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

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

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:

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

Paper Reference. Paper Reference(s) 1776/04 Edexcel GCSE Modern Greek Paper 4 Writing. Thursday 21 May 2009 Afternoon Time: 1 hour 15 minutes

Paper Reference. Paper Reference(s) 1776/04 Edexcel GCSE Modern Greek Paper 4 Writing. Thursday 21 May 2009 Afternoon Time: 1 hour 15 minutes Centre No. Candidate No. Paper Reference(s) 1776/04 Edexcel GCSE Modern Greek Paper 4 Writing Thursday 21 May 2009 Afternoon Time: 1 hour 15 minutes Materials required for examination Nil Paper Reference

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

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:

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

Matrices and Determinants

Matrices and Determinants Matrices and Determinants SUBJECTIVE PROBLEMS: Q 1. For what value of k do the following system of equations possess a non-trivial (i.e., not all zero) solution over the set of rationals Q? x + ky + 3z

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

Finite Field Problems: Solutions

Finite Field Problems: Solutions Finite Field Problems: Solutions 1. Let f = x 2 +1 Z 11 [x] and let F = Z 11 [x]/(f), a field. Let Solution: F =11 2 = 121, so F = 121 1 = 120. The possible orders are the divisors of 120. Solution: The

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

Εργαστήριο ΔΙΑΧΕΙΡΙΣΗ ΑΡΧΕΙΩΝ & ΚΑΤΑΛΟΓΩΝ ΣΤΟ UNIX. Εισαγωγή

Εργαστήριο ΔΙΑΧΕΙΡΙΣΗ ΑΡΧΕΙΩΝ & ΚΑΤΑΛΟΓΩΝ ΣΤΟ UNIX. Εισαγωγή Εισαγωγή Εργαστήριο 2 ΔΙΑΧΕΙΡΙΣΗ ΑΡΧΕΙΩΝ & ΚΑΤΑΛΟΓΩΝ ΣΤΟ UNIX Συνεχίζουμε την εργαστηριακή μελέτη των Λειτουργικών Συστημάτων εξετάζοντας τις δομές των αρχείων και καταλόγων και τη διαχείρισή τους στο

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

ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ

ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ ΕΛΕΝΑ ΦΛΟΚΑ Επίκουρος Καθηγήτρια Τµήµα Φυσικής, Τοµέας Φυσικής Περιβάλλοντος- Μετεωρολογίας ΓΕΝΙΚΟΙ ΟΡΙΣΜΟΙ Πληθυσµός Σύνολο ατόµων ή αντικειµένων στα οποία αναφέρονται

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