User Tools

Site Tools


blog:spring2016:klymber:journal

This is an old revision of the document!


HPC Fundamentals Journal

MONTH Day, YEAR

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • Why was this significant?
  • What concepts are you dealing with that may not make perfect sense?
  • What challenges are you facing with respect to the course?

Systems Programming Journal

April 20, 2016

Gchat 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 #include <sys/mman.h> 5 #include <sys/stat.h> 6 #include <fcntl.h> 7 #include <sys/types.h> 8 #include <sys/wait.h> 9 #include <signal.h> 10 #include <string.h> 11 12 13 14 int quit; 15 16 void finish(); 17 18 int main() 19 { 20 char c; 21 char d; 22 char f; 23 char cw; connection wait 24 char cwm = 8; connection wait max 25 int fd[10]; 26 char line[80]; 27 int x; 28 pid_t p; 29 char name[2]; 30 char myname[] = { '6', '\0' }; 31 quit = 0; 32 33 34 fd[9] = shm_open(myname, O_RDWR | O_CREAT, 0666); 35 if (fd[9] == -1) 36 { 37 fprintf(stderr, “Error.\n”); 38 exit(1); 39 } 40 fprintf(stdout, “Write channel established!\ n”); 41 42 fprintf(stdout, “Bringing shmchat online…\ n”); 43 for (x = 0; x < 9; x++) 44 { 45 cw = 0; 46 name[0] = x + 48; 47 name[1] = '\0'; 48 d = 0; 49 50 p = fork(); 51 if (p == 0) 52 break; 53 } 54 55 if (p == 0) 56 { 57 while (d == 0) 58 { 59 fd[x] = shm_open(name, O_RDONLY, 0640); 60 if (fd[x] == -1) 61 { 62 if (cw < cwm) 63 { 64 fprintf(stdo ut, “Waiting on %s …\n”, name); 65 } 66 sleep(1); 67 cw = cw + 1; 68 } 69 else 70 { 71 d = 1; 72 fprintf(stdout, “[%s ] Connection established!\n”, name); 73 } 74 } 75 76 d = 0; 77 while (read(fd[x], &c, 1) != -1) 78 { 79 line[d] = c; 80 if (c != '\n') 81 { 82 fprintf(stdout, “”); 83 d = d + 1; 84 f = 0; 85 } 86 else 87 { 88 fprintf(stdout,“[%d] : ENTER\n”, x); 89 line[d+1] = '\0'; 90 d = 0; 91 if (f == 1) 92 f =2; 93 else if(f == 0) 94 f = 1; 95 } 96 sleep(1); 97 if 1) 98 { 99 if(strlen(line) != 1 ) 100 fprintf(stdo ut, “[%d]: %s”, x, line); 101 line[0] = '\0'; 102 f = 0; 103 } 104 } 105 } 106 else parent 107 { 108 signal(SIGINT, finish); 109 while 2) && quit == 0) 110 { 111 c = fgetc(stdin); 112 if (c == '~') 113 break; 114 write(fd[9], &c, 1); 115 } 116 117 shm_unlink(myname); 118 119 for (x = 0; x < 9; x++) 120 wait(NULL); 121 } 122 123 return(0); 124 } 125 126 127 void finish() 128 { 129 quit = 1; 130 }

MARCH 24, 2016

Yet again for no reason other than I have trouble posting things I have learned because I never know what exactly to say. So here I go, I have done quite a bit this semester! I have explored multiple different Linux operating systems and currently configuring my very own home server! I have Learned about about threading, forking and general concurrency. Concurrency is when your program is broken into sub units that all work together to get a single job done. Threads and forks are similar yet different because with forks we had to have each fork write its values into a text file then read each one back in the correct order. Threads still elude me but I have had some ideas that I have been unable to complete that I believe when implemented correctly they will work and pretty efficient as well! Prime numbers are cool, I really enjoy creating an efficient program and comparing them to friends, healthy competition is great for progress in my opinion.

1)
d == 0) && (f == 1
2)
!feof(stdin
blog/spring2016/klymber/journal.1461168094.txt.gz · Last modified: 2016/04/20 16:01 by klymber