Today was the first day of Computer Organization. In it, we very, very vaguely talked about what the course would be about. We've all been here in Computer-based programs for a while now, so there wasn't much need for the usual introduction. We started by talking about how a computer actually sees things– not as ones and zeros per se, but as electrical signals. It is as though one is given only two things, and from these two things only, the he must build whatever he wants. Afterwards, we were tasked with writing 0 through 63 in binary. A large group in the class worked up on the board. They split the work up in to sections, each person having a set number to complete. Derek and I worked separately from that group, and from each other, but we seemed to get it all done faster (not to sound like a snot, or anything.) I mean, it is only counting. I don't think the group is bad at it, I just think they thought about it in a way that made it harder than it was. Anyhow, I hope we get to some coding soon.
As for the rolling class schedule that is HPC II, I talked to Matt and I've settled on two projects on which to start. I'm going to be making my one gaming PC in to two with the help of new parts and old, so one of my projects will be the assembly and set up of each. It will be well documented so as to be a how-to guide (let's face it, building computers is easy once you've done it, but it can be rather daunting if you haven't). My other project will involve a guide for setting up wireless on the model of netbook I have when Linux Mint Debian edition is installed. This seems to be a problem for many people, myself included, who use the OS in general, and there are many different fixes that may or may not work generally. So, even though I have already figured out how to get mine to work, I will try to document the process as best I can. More on both of those projects later.
Today, we talked about sneeches and flabulators. Some sneeches have stars, and others do not. A tunnel flabulator does not change a sneech, but a vortex flabulator does. …We made a truth table?
Okay, basically, the lesson represented how a computer handles bits (sneeches, in this case) to send instructions. We made a truth table to represent how two sets of four bits could be manipulated based on various conditions in order to send certain instructions. That was about it for Computer Organization.
As for HPC, I asked Matt if I could do another project based off of my computer building project, which involves making benchmarks for my soon to be created system on Nvidia PhysX enabled games between the system using only one card (a GTX 560 Ti) or that same card along with a lesser card (9600 GT) as a PhysX dedicated card. That will be an interesting project, I think. I just need to check to see if there are certain attributes I need to be meeting for these HPC II projects.
Things have been going relatively slow in ASM so far. We've just been talking about logic gates and how the processor functions in general. Don't get me wrong, this is very interesting stuff, but we usually had these sort of discussions along with some code analysis. As in, Matt would write some code for us to compile and study up on the board, and discussion with model drawing and all that would compliment the code to drive the point home. We're just getting started, so it's to early to tell what we'll be up to for the whole semester.
As for HPC II, Matt told me that my own little personal second excursion in to SDL could count as a project. I figured it would be worth looking in to on its own, but I didn't even consider the possibility of it being a project. This works for me though. If I can keep it up, I have so grandiose plans for it all. I am using the Lazy Foo' guide yet again, and I am up to Lesson 6. I'm learning quite a bit, as it is an excellent guide. I wish I had more time to work on it all, though.
Today was a rather interesting class. Unfortunately, I did have to leave early for a dentist appointment (which went well, for what it is worth!). In class, however, we had a nice discussion on registers, including what they are and how they function in a basic sense. Derek was able to draw a very nice diagram of a register, simply from his experiences in our high school engineering program, which is honestly impressive. We talked about how a register is essentially storage in the processor for commonly executed tasks. This makes it easier for the computer to be efficient, as less work is needed to execute said tasks.
As for HPC II, my progress has been partially slowed by other work. I have some nice projects lined up, and they will be started and completed soon. My SDL adventure is also taking a bit of a break so that other more pressing tasks can be completed. However, I left off on lesson 8, so progress has been made. I can't wait until I learn more, as making games with what I've learned is a very exciting prospect.
Today was a particularly interesting class in Comp. Org., as we discussed some ~*particularly interesting*~ things. We went over Karl's meticulous and painstakingly printed on-board explanation of the Fetch-Execute cycle (recently catch-phrased into the trendy “fetchecute” cycle), which could be described simply as the method by which the computer executes an instruction and proceeds to acquire (or, fetch) a new one. This led in to our discussion about Turing machines, which are wonderful devices of which there are no physical manifestations. Simply, it is a method of thinking developed by Alan Turing which led to the development of modern day computing. We had a nice little visual representation on the board drawn to represent the Turing machine's hypothetical infinite storage tape from which we spent the remainder of class trying to figure out how many symbols we would need to have the Turing machine print a certain sequence.
A Logical Operator is a “connector” of sorts between two items with value, which then in turn yields a truth value based on the truth value of those two items. In relation to the course, this would of course reference the electrical signals sent through the processor (on and off, 1 and 0, etc.).
The logical operator AND takes two items and will only yield a truth value of true if both of those items also have a truth value of true. In the scope of the course, this means a couple things– of course, we use AND as “&&” in C/C++ code for a conditional statement. In terms of a processor, AND will only yield an on signal if both input signals are on, so to speak.
The logical operator OR will yield a true value so long as one of the inputted truth values is also true. In relation to the course, we also use this operation in our code, as shown by the “||” operator in C/C++. In terms of the hardware, an on signal is sent when one or two on signals is received.
The logical operator XOR is the exclusive or operation. This means that it is a lot like OR, except that it will only yield a true value if and only if one of the two truth values are true. That is to say, having both values be true will not yield a true value under XOR.
As we know, some examples of logical operators include AND, OR and XOR.
If we were to make a small bitwise truth table to demonstrate these concepts, it would look like this–
A O X N R O D R -------------------- 1 1 |1 1 0 1 0 |0 1 1 0 1 |0 1 1 0 0 |0 0 0
Here is a code snippet of AND being used in C:
//AND in C if( x == 1 && y == 1) { exampleFunction(); } //OR in C if( x == 1 || y == 1) { exampleFunction(); } //XOR in C if( (x == 1 && y == 0) || (x == 0 && y == 1) ) { exampleFunction(); }
A negated logic operator is precisely what it sounds like– it takes our standard logic operator, and essentially negates them in the sense that it yields true values based on whether or not given truth values are false. They could be called opposites of the regular logic operators. Examples include NOR, NAND, XNOR, and NOT.
NOR yields a true value if and only if no given conditions are true. It is the inverse of OR.
NAND yields a true value if one given condition is not true. The yielded value is false if both given are true. It is the inverse of AND.
XNOR is exclusive NOR. It yields true only if both given conditions are true, or both are false. It is the inverse of XOR.
NOT simply inverts the given truth values (usually in the form of bits). True becomes false, false becomes true.
As is such, every negated logic operator is essentially a logic operator put through NOT.
N X | | N A N | | O N O | | R D R | NOT Inversion | ------------------------------- 1 1 |0 0 1 |1| -> 0 1 0 |0 1 0 |1| -> 0 0 1 |0 1 0 |1| -> 0 0 0 |1 1 1 |0| -> 1
//NAND in C if(!(x == 1 && y == 1)) { exampleFunction(); } //NOR in C if(!(x == 1 || y == 1)) { exampleFunction(); } //XNOR in C if(!((x == 1 && y == 0) || (x == 0 && y == 1))) { exampleFunction(); }
Storage is simply the various parts of the computer that are used to store the digital data that is used and created. This can refer to many things, including hard disks, RAM, registers, solid state drives and more.
It is worth noting that there are varying degrees, so to speak of storage. That is, there is primary, secondary, tertiary and off-line.
Primary storage is can be accessed directly by the CPU. An example of this would be RAM.
Secondary storage is non-volatile and can't be accessed by the CPU directly. An example would be a hard disk drive.
Tertiary storage is usually used for archiving, as it takes much longer to access than secondary storage. An example would be a tape cartridge.
Off-line storage is storage independent of a processing unit. An example would be a an optical disc drive.
<html> <img src=“http://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/Computer_storage_types.svg/350px-Computer_storage_types.svg.png”> </html>
[Source: Wikipedia: Computer Storage ]
Simply, a register is a small amount of storage on the processor that contains instructions for completing simple or commonly used tasks. With these instructions being stored in a storage location on the processor, it is much easier to access, which makes these processes quicker.
Data registers can hold data in the form of integers and floating point values. Older CPUs, like the one we seek to emulate, have a special register called an accumulator that deals with that data specifically.
A 4-bit register. [Source: http://cpuville.com/register.htm]
Before defining this word, it is important to understand what a bus is. Simply, it is a subsystem that forms a connection between components for the transfer of various forms of data.
Now, an Address Bus is the bus that is used to specifically address a memory location. That is to say, when one component (say the CPU) needs to access data, the memory address of this data is transmitted through the address bus.
<html> <img src=“http://common.ziffdavisinternet.com/encyclopedia_images/ADDRSBUS.GIF”> </html>
[Source: PC Mag Encyclopedia ]
Before defining this word, it is important to understand what a bus is. Simply, it is a subsystem that forms a connection between components for the transfer of various forms of data.
The Data Bus is the bus on which a certain value is transmitted. To put it in perspective, if the the address bus transmits a memory location, the data bus transmits the value stored in this memory location.
Below is a system bus, highlighting how each specific bus interfaces with the other components of the computer.
<html> <img src=“http://upload.wikimedia.org/wikipedia/commons/thumb/6/68/Computer_system_bus.svg/400px-Computer_system_bus.svg.png”> </html>
[Source: Wikipedia: Bus (computing)]
Control Flow refers to the order or method by which instructions are carried out by the computer. This encompasses the types of conditional statements and functions (subroutines) that we would see in our programming code.
Data Flow, on the other hand, refers to the stream of information that is passed around the computer's components. It is not concerned with how and when like control flow, but rather where and what.
<html> <img src=“http://upload.wikimedia.org/wikipedia/commons/thumb/e/e3/Performance_seeking_control_flow_diagram.jpg/454px-Performance_seeking_control_flow_diagram.jpg” height=500> </html>
Above is an example of control flow, in diagram form. Obviously, the diagram has subject matter not pertaining to computer science, but the logic of control flow is there, which is the focus. [Source: Wikipedia: Control Flow diagram]
<html> <img src=“http://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/DataFlowDiagram_Example.png/360px-DataFlowDiagram_Example.png”> </html>
Above is an example of data flow, in diagram form [Source: Wikipedia: Data Flow diagram]
Boolean Arithmetic Operations are algebraic operations that are used on boolean or binary values. The typical operations of addition, subtraction, multiplication and division are either fundamentally different or non-existent in the scope of boolean algebra. To explain the latter, it is worth knowing that there is no such thing as subtraction, as that would require negative numbers, and division, as it is compounded subtraction just as multiplication is compounded addition, in boolean algebra.
Luckily, addition and multiplication still exist, though this is self-evident. Simply, boolean addition will yield a 1 or true value so long as there is a 1/true value being added. Multiplication will yield a 1/true value if and only if there are no zeros involved.
Below are some examples of boolean addition and multiplication. As you can see, they use standard mathematical notation, logic gate representation and circuitry representation.
Addition <html> <p> <img src=“http://sub.allaboutcircuits.com/images/14009.png” height=100> </p>
<p>
</p>
<p> <img src=“http://sub.allaboutcircuits.com/images/14010.png” height=100> </p>
<p>
</p>
<p> <img src=“http://sub.allaboutcircuits.com/images/14011.png” height=100> </p>
<p>
</p>
<p> <img src=“http://sub.allaboutcircuits.com/images/14012.png” height=100> </p>
<p> </html>
Multiplication <html> <p> <img src=“http://sub.allaboutcircuits.com/images/14013.png” height=75> </p>
<p>
</p>
<p> <img src=“http://sub.allaboutcircuits.com/images/14014.png” height=75> </p>
<p>
</p>
<p> <img src=“http://sub.allaboutcircuits.com/images/14015.png” height=75> </p>
<p>
</p> <p> <img src=“http://sub.allaboutcircuits.com/images/14016.png” height=75> </p>
<p> </html>
Personally, I think that meeting this objective means having a thorough understanding of how the various number systems we use (binary, octal, decimal, hexidecimal, etc.) in computer science work, along with an appreciation of how they let us solve problems and think of situations in different ways.
I'm not sure if there is any one test that would prove that I have met this objective, but I do think that a small discussion about the topic in the below space should suffice.
Suffice it to say, number systems have a profound impact on our field, computer science, and an understanding of such is integral to our success. As previously stated, using different number systems lets us look at problems in different ways. Thinking in terms of a different number system may help one understand how a certain component or program works.
The main number systems covered in our course thus far (decimal, binary, octal and hexadecimal) all have their place in computer science and in the very computers we work with. Chief among these number systems would be binary, as it is the representation of how the hardware works at the most basic level, which is to say the electrical signals being sent in the circuitry. One would not get very far as in this class, let alone as a CS major, without understanding the implications of the binary number system.
Another important system would be hexidecimal, which is often used in addressing memory locations, and, in a less pertinent matter, the colors displayed in our programs and web pages.
Generally speaking, understanding that numbers can be looked at in a different way than we grew up with in decimal speaks to a larger message that all computer science majors should abide by. That message is of course that with computing, there is always more than one way to get the job done.
Upon further analysis, I do believe I get it.
bool numberSystems; bool important = true; numberSystems = important; while(numberSystems == important) { tylerGetsIt(numberSystems, important); }
A partition is a logical division of storage space on a hard drive. In essence, partitioning your hard drive is like turning your one drive in to multiple, as far as the computer is concerned. Of course, this is only logical– the physical drive is treated as multiple logical drives.
Below, is a graphical representation of the partitioning of a hard drive, shown through the program GParted.
There is a ext4 filesystem partition, on which the shown OS is installed, a linux swap partition, and unallocated space.
The kernel is generally the main component of the operating system. It acts as the middleman between the hardware (cpu, memory, etc.) and the software applications being run on the OS by managing the system's resources and letting the software being run to use those resources.
Simply: [Hardware] <---> [Kernel] <---> [Software]
On an OS with unix, you can check your current kernel version like so:
tyler@aleron ~ $ uname -a Linux aleron 3.0.0-1-amd64 #1 SMP Sun Jul 24 02:24:44 UTC 2011 x86_64 GNU/Linux
A kernel module is code that can be loaded in to a kernel at any time. In doing so, the functionality of the kernel is expanded accordingly. Without kernel modules, the kernel would have to be rebuilt every single time new functionality is added, which obviously is not efficient or convenient.
Behold, a part of the list of the kernel modules on my system–
…and the long version. Use the “lsmod” command to list all of your modules.
tyler@aleron ~ $ lsmod Module Size Used by arc4 12458 2 brcmsmac 528689 0 brcmutil 13419 1 brcmsmac mac80211 182631 1 brcmsmac cfg80211 132564 2 brcmsmac,mac80211 crc_ccitt 12347 1 brcmsmac pci_stub 12429 1 vboxpci 19059 0 vboxnetadp 13202 0 vboxnetflt 23595 0 vboxdrv 194054 3 vboxpci,vboxnetadp,vboxnetflt powernow_k8 17688 1 mperf 12453 1 powernow_k8 cpufreq_conservative 13147 0 cpufreq_userspace 12576 0 cpufreq_stats 12862 0 ...
modprobe is a program in Linux that allows the user to manage the kernel modules that are loaded. As is such, using modprobe on the command line allows one to add or remove a module from the kernel. It can be useful when certain functionality on the system is not working like it should, as sometimes reloading a module will fix a problem.
tyler@aleron ~ $ man modprobe tyler@aleron ~ $ modprobe [module name to be added] tyler@aleron ~ $ modprobe -r [module to be removed] tyler@aleron ~ $ modprobe -a [module to be added] [module to be added] [module to be added]
Synaptic Package Manager is a graphical Linux program that lets one manage the software packages installed on the system. It is the graphical version of the package managing program apt. As is such, it is an important program that most every Linux user should be familiar with, as it is key to maintaining one's system in a desirable manner.
Behold, Synaptic running on my system.
You can see the list of packages here. They can be searched through and categorized based on type.
Every modern computer has some sort of graphical display processing unit as one of its many components. As one might imagine, there are different types to suit the needs of different users. This keyword serves as a general definition of the two general types one will find.
Dedicated GPUs work independently of the computer's CPU and/or motherboard. They are most often hooked in to PCI Express (modernly, that is. In the not too distant past, AGP and PCI interfaces were the norm) buses on the motherboard, and feature their own board and chipset. Dedicated cards are used for more resource intensive processes, such as gaming and computer aided design (or, CAD). As is such they are much more powerful than integrated chipsets, typically, and require greater cooling solutions, such as a large fan and heatsink specifically for the card.
Integrated GPUs, on the other hand, are either found on the motherboard, or, in recent times, within the main processor (seen in Intel's Core iX series and AMD's Fusion line). This usually means a weaker graphics processing experience, but it comes with the advantage of less space and power used. These solutions are suitable for general use, but not for more demanding processes.
Simply put, being that a computer runs on electricity, it is bound to get warmer and warmer as the system does work (requiring more electricity). Performance will suffer proportionately to how hot the system's components become. That is why it is necessary to utilize proper system cooling solutions, generally listed below.
One cooling solution would be air cooling. We know this simply as the fans that run within our cases. They blow air on to and or away from system components in order to maintain lower temperatures.
Another cooling solution that is commonly used would be heat dissipation. This takes the form of heat-sinks which are pieces of various metallic materials attached to components that are designed in such a way to absorb heat and spread it across itself, which keeps heat from building up in a concentrated area.
Finally, a less common, yet very effective and expensive solution is water cooling, which uses tubes to circulate cooled water on to components' surfaces to keep cool. As is such, it is highly effective, but is not very practical in the sense that it is quite expensive, comparatively.
[Source: Gizmodo]
Advanced Packaging Tool, or APT is a program for Linux that lets you manage the packages on a system. It is a command line driven program. As with Synaptic, this is a program that Linux users should be familiar with, as packages can be installed simply with the use of a command. This is, of course, very useful if you know what packages you want to install already. Another terminal based program, aptitude provides a higher level interface to the package manager, but operates much like apt in many cases.
tyler@aleron ~ $ sudo apt-get update [sudo] password for tyler: Ign http://ftp.us.debian.org squeeze InRelease Hit http://ftp.us.debian.org squeeze Release.gpg Hit http://ftp.us.debian.org squeeze Release Get:1 http://security.debian.org testing/updates InRelease [87.8 kB] Hit http://debian.linuxmint.com testing InRelease Hit http://ftp.us.debian.org squeeze/main amd64 Packages Hit http://ftp.us.debian.org squeeze/contrib amd64 Packages Hit http://ftp.us.debian.org squeeze/non-free amd64 Packages Ign http://ftp.us.debian.org squeeze/contrib TranslationIndex Hit http://ftp.us.debian.org squeeze/main TranslationIndex Hit http://debian.linuxmint.com testing/main amd64 Packages/DiffIndex Ign http://ftp.us.debian.org squeeze/non-free TranslationIndex Ign http://www.debian-multimedia.org testing InRelease Hit http://debian.linuxmint.com testing/contrib amd64 Packages/DiffIndex Hit http://debian.linuxmint.com testing/non-free amd64 Packages/DiffIndex Ign http://debian.linuxmint.com testing/contrib TranslationIndex Hit http://debian.linuxmint.com testing/main TranslationIndex Ign http://debian.linuxmint.com testing/non-free TranslationIndex Get:2 http://security.debian.org testing/updates/main amd64 Packages [14 B] Get:3 http://www.debian-multimedia.org testing Release.gpg [198 B] Get:4 http://security.debian.org testing/updates/contrib amd64 Packages [14 B] Get:5 http://security.debian.org testing/updates/non-free amd64 Packages [14 B] Ign http://security.debian.org testing/updates/contrib TranslationIndex Ign http://security.debian.org testing/updates/main TranslationIndex Get:6 http://www.debian-multimedia.org testing Release [32.1 kB] Ign http://security.debian.org testing/updates/non-free TranslationIndex Ign http://ftp.us.debian.org squeeze/contrib Translation-en_US Ign http://ftp.us.debian.org squeeze/contrib Translation-en Ign http://ftp.us.debian.org squeeze/non-free Translation-en_US Ign http://ftp.us.debian.org squeeze/non-free Translation-en Get:7 http://www.debian-multimedia.org testing/main amd64 Packages/DiffIndex [2,023 B] Ign http://debian.linuxmint.com testing/contrib Translation-en_US Ign http://debian.linuxmint.com testing/contrib Translation-en Ign http://debian.linuxmint.com testing/non-free Translation-en_US Ign http://debian.linuxmint.com testing/non-free Translation-en Get:8 http://www.debian-multimedia.org testing/non-free amd64 Packages/DiffIndex [2,023 B] Ign http://www.debian-multimedia.org testing/main TranslationIndex Ign http://www.debian-multimedia.org testing/non-free TranslationIndex Get:9 http://www.debian-multimedia.org testing/main amd64 Packages [72.7 kB] Ign http://security.debian.org testing/updates/contrib Translation-en_US Ign http://security.debian.org testing/updates/contrib Translation-en Ign http://security.debian.org testing/updates/main Translation-en_US Get:10 http://www.debian-multimedia.org testing/non-free amd64 2012-03-03-1139.41.pdiff [361 B] Get:11 http://www.debian-multimedia.org testing/non-free amd64 2012-03-03-1139.41.pdiff [361 B] Ign http://security.debian.org testing/updates/main Translation-en Ign http://security.debian.org testing/updates/non-free Translation-en_US Ign http://security.debian.org testing/updates/non-free Translation-en Ign http://www.debian-multimedia.org testing/main Translation-en_US Ign http://www.debian-multimedia.org testing/main Translation-en Ign http://www.debian-multimedia.org testing/non-free Translation-en_US Ign http://www.debian-multimedia.org testing/non-free Translation-en Ign http://packages.linuxmint.com debian InRelease Get:12 http://packages.linuxmint.com debian Release.gpg [197 B] Get:13 http://packages.linuxmint.com debian Release [12.2 kB] Get:14 http://packages.linuxmint.com debian/main amd64 Packages [12.6 kB] Get:15 http://packages.linuxmint.com debian/upstream amd64 Packages [5,192 B] Get:16 http://packages.linuxmint.com debian/import amd64 Packages [20.2 kB] Ign http://packages.linuxmint.com debian/import TranslationIndex Ign http://packages.linuxmint.com debian/main TranslationIndex Ign http://packages.linuxmint.com debian/upstream TranslationIndex Ign http://packages.linuxmint.com debian/import Translation-en_US Ign http://packages.linuxmint.com debian/import Translation-en Ign http://packages.linuxmint.com debian/main Translation-en_US Ign http://packages.linuxmint.com debian/main Translation-en Ign http://packages.linuxmint.com debian/upstream Translation-en_US Ign http://packages.linuxmint.com debian/upstream Translation-en Fetched 248 kB in 6s (39.4 kB/s) Reading package lists... Done tyler@aleron ~ $
tyler@aleron ~ $ sudo apt-get install [package to be installed]
While I think the objective's meaning is self-evident, I will try to elaborate. Simply put, one should be able to be more efficient and effective of a troubleshooter. Issues should be identified sooner, with possible solutions researched and attempted. Ultimately, the problem should be solved much sooner than it would have if the course was not taken.
Well, the only way to find out if I achieved this objective is to solve problems. Solving a major problem with any system on my own should prove that I have met this objective.
I can list a couple different examples of why I have met (or will meet) this objective–
There's always room to improve when it comes to troubleshooting, so that will come in time. I think I am a decent troubleshooter as is. The measurement process could stand to be a little more objective, but the actual objective is a little subjective. I'm not entirely sure how to improve upon the objective, though.
Though this problem has already been solved, this will serve as a sort of retroactive experiment. In the beginning of the semester, I was having issues with my netbook's Linux Mint Debian installation and the wireless connection. After much troubleshooting, I was able to solve it, but only if I removed and reloaded a module from the kernel. Naturally, this is kind of annoying to do each time when I start up, so naturally the question was asked– “Could I use a start up script to solve this wireless issue?”
The answer may (or may not) surprise you.
Being that it takes only a couple terminal commands to fix the situation via modprobe, adding these commands to a script that runs at start up should fix my wireless issues. Matt suggested that I add them to “/etc/rc.local”.
The experiment is simple– add the commands to the start up script (/etc/rc.local), restart the computer and check to see if the wireless issue is resolved.
modprobe -r brcmsmac modprobe brcmsmac
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bitso # # By default this script does nothing. mkdir -p /dev/cgroup/cpu mount -t cgroup cgroup /dev/cgroup/cpu -o cpu mkdir -m 0777 /dev/cgroup/cpu/user echo "/usr/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent modprobe -r brcmsmac modprobe brcmsmac exit 0
Ultimately, the script works. My wireless starts up perfectly each time the system boots.
Scripts can do many a great thing, even if it is something as simple as this. This was resulted in my system acting as it should, after a great deal of stress and Googling. There was SO much Googling. Too much, even. Even so, I learned a great deal about the workings of a Linux system through the troubleshooting process. Really, that is how I've learned most things about computer maintenance and set up– break something, stress a lot, fix it somehow, lesson(s) learned.
Simply put, I wrote some code snippets for some of my keywords regarding logic operators. I wanted to make sure that the code was valid, so this is the experiment that puts these code snippets to the test. The question being, “Is my syntax correct in such a way that the concepts of the basic logic gates are accurately displayed?”
Naturally, my hypothesis is that my code is correct, otherwise I wouldn't have written it as such. This experiment is solely to make sure. For science!
Simply, I will run the program (code is below) with every possible input for two items ([1,1], [1,0], [0,1], [0,0]), and check to see if the logic gates are working as they should, according to the definitions provided above, in the keywords section. If they are working as they should, then my hypothesis is correct.
#include<stdio.h> int main() { int x,y; do { printf("Enter an X value (0/1): "); scanf("%d", &x); if (x < 0 || x > 1) { printf("ERROR: Please enter either a 0 or 1. \n"); } } while (x < 0 || x > 1); do { printf("Enter a Y value (0/1): "); scanf("%d", &y); if (y < 0 || y > 1) { printf("ERROR: Please enter either a 0 or 1. \n"); } } while (y < 0 || y > 1); //AND in C if( x == 1 && y == 1) { printf("AND: True\n"); } else { printf("AND: False\n"); } //OR in C if( x == 1 || y == 1) { printf("OR: True\n"); } else { printf("OR: False\n"); } //XOR in C if( (x == 1 && y == 0) || (x == 0 && y == 1) ) { printf("XOR: True\n"); } else { printf("XOR: False\n"); } //NAND in C if(!(x == 1 && y == 1)) { printf("NAND: True\n"); } else { printf("NAND: False\n"); } //NOR in C if(!(x == 1 || y == 1)) { printf("NOR: True\n"); } else { printf("NOR: False\n"); } //XNOR in C if(!((x == 1 && y == 0) || (x == 0 && y == 1))) { printf("XNOR: True\n"); } else { printf("XNOR: False\n"); } return(0); }
tyler@aleron ~/src/asm $ ./logicgates Enter an X value (0/1): 1 Enter a Y value (0/1): 1 AND: True OR: True XOR: False NAND: False NOR: False XNOR: True tyler@aleron ~/src/asm $ ./logicgates Enter an X value (0/1): 1 Enter a Y value (0/1): 0 AND: False OR: True XOR: True NAND: True NOR: False XNOR: False tyler@aleron ~/src/asm $ ./logicgates Enter an X value (0/1): 0 Enter a Y value (0/1): 1 AND: False OR: True XOR: True NAND: True NOR: False XNOR: False tyler@aleron ~/src/asm $ ./logicgates Enter an X value (0/1): 0 Enter a Y value (0/1): 0 AND: False OR: False XOR: False NAND: True NOR: True XNOR: True tyler@aleron ~/src/asm $
My hypothesis was correct– the code compiles, and the logic gates work as intended, as demonstrated above.
It is worth noting that I did not use the bitwise operators here, however. In C, there actually is a bitwise operator for xor. Obviously, I did not do that, opting only for the logical operators the language provides. Perhaps a bitwise version of this will come in handy later. I did notice that I could have made the XOR and XNOR gates more efficient, code-wise. It's essentially checking to see if the two values are the same, so the condition could be if x==y or !(x==y), respectively, instead. Oh well! The experiment wasn't so much to make super efficient code, it was to test the code I whipped up in a minute.
A discussion in class led to the question being posed regarding the nature of the NOT operator in C/C++. We wondered what happened if an integer is defined as a given number and then has the NOT operator applied to it. We know that if the number is 1, we will get a zero. But what if the number is larger than 1? What if it is an arbitrarily large number? This is what the experiment seeks to answer.
One might think that the number returned would be negative (for whatever reason?), but given that using NOT on 1 yields 0, it is likely that using it on a different number will yield 0 as well.
I will be testing this by writing code that accepts an inputted number, runs NOT on it, then prints the result.
#include<stdio.h> int main() { int a, b; printf("Please enter a value to use NOT on: "); scanf("%d", &a); b=!a; printf("a = %d\nb = %d\n!b = %d\n", a, b, !b); return(0); }
tyler@aleron ~/src/asm $ ./notexp Please enter a value to use NOT on: 1 a = 1 b = 0 !b = 1 tyler@aleron ~/src/asm $ ./notexp Please enter a value to use NOT on: 3 a = 3 b = 0 !b = 1 tyler@aleron ~/src/asm $ ./notexp Please enter a value to use NOT on: 9001 a = 9001 b = 0 !b = 1
My hypothesis was correct, and Karl's original test checks out. The not operation, when placed on a variable, will yield a 0 if the variable is another number other than that, and a 1 if it is zero.
My conclusion is largely in the analysis portion of this experiment. But, through this experiment, it has become clear that the NOT operator in C/C++ will serve as a valuable tool in our CPU simulation project.