Intro to Unix ECE 2524 Entry #9

I’ve been enjoying the break finishing up all the current unix assignments before the break began. I guess the last thing I did that I haven’t mentioned yet is the future of unix paper.  I thought this was an interesting paper to write about and research as technology in the future has always been an interest of mine. Upon finishing the paper I didn’t realize that part of the submission was creating a makefile to convert the paper to html and pdf. Since I started this paper in Word I wasn’t sure where to go and how to get it in to markdown format. Turns out markdown format is pretty much just plain text, so I was able to take the plain text file and simply add some white space where paragraphs were needed which wasn’t nearly as bad as I thought it would be. After getting the markdown file, converting it using pandoc was as simple as just googling what the command to do so was. Setting up the makefile after this was a piece of cake.

In 3574, we are getting a bunch of homeworks as he is trying to squeeze everything into these last couple of weeks which is really annoying. So we got stuck with an assignment over break. This proved to be pretty tough especially without being able to go see the TA for help.  The homework was on POSIX message queues.  I managed to set up everything necessary for the homework, but was stuck on one of the most trivial parts. The parameter for the message in the send and receive functions is a char*. I didn’t realize how annoying this was to convert my messages between char*s and QStrings.  Turns out everything I was doing wrong had to do with my error in conversion. I was using the same char* as my send and receive message because I didn’t realize how it was really storing the information into the pointer.  By having 2 char*s, one for receiving, and one for sending, this cleared up the issue. Such a small thing for all the debugging I had to do. Debugging for this homework was extremely annoying since you had to run 4 separate processes of the same program, then a fifth process of a different program. All 5 processes had to be run in a certain order, and remade, and reran every time I made a small change. It would take about 30 seconds just to get to the point where I could rerun the program. I finally got it working though after a few emails with the TA,

Intro to Unix ECE 2524 Entry #8

I’ll go ahead and start off this blog by talking about the makefile assignment since I haven’t said anything about that yet.  At first, I thought making a makefile would be extremely difficult; I figured that since the process was often automated it must be very hard. I actually found it to be very intuitive for the most part. Each target will be re-created based on any dependencies that it has, so if any of its dependencies change then the target will be recreated based upon the commands listed for that target. I found especially beneficial that you can have multiple targets if they have the same dependencies and are created by the same commands, this came in handy for the parser.tab.hpp, and parser.tab.cpp files which were both dependent on parser.ypp and were created by the same bison command.

The most recent assignment was on forking processes and creating a pipe.  The first part of the assignment was to create a makefile which proved to be very easy after the last homework.  For the most part the homework was very straightforward and took nothing more than looking at examples and reading the man pages.  Of course I had a couple small bugs, but Darren pointed me in the right direction with these issues, and I got the homework finished without too much trouble.  I have a lot more experience in C++ so it is a lot easier for me to write C++ code then it was with writing Python which was a struggle especially through poor documentation.  I thought this was a cool assignment that showed how the beginnings of a shell may come together.

The most recent assignment in 3574 wasn’t too difficult after some guidance from Sean.  This goal of this homework was to use threads to perform matrix multiplication.  Reading from the input file actually proved to be more difficult than I had expected since Sean told me he would probably do a of error checking by supplying oddly formatted input files.  He showed me how to use QRegExp (regular expressions) to get a good pattern for determining if the input is an int or a float, and then if the input didn’t match either of those then you know that there is something wrong with the input. This eliminates the need to check for a multitude of different things such as if there are letters entered, or special characters, or who know’s what else. The regular expression catches it all with ease.  I read the input files into a QList of QStringLists, which gave me access to the matrix elements in a similar way to a 2-D array.  After that it was pretty easy just to run a for loop to make the correct number of threads, calculate the correct products then output it to the resultant matrix.  I found that there was no need for mutexes since there is no thread was going to access to the same memory location, so this made the assignment even easier.