My name is Kyle.
I'm a

software engineer?

programmer?

developer?

coder?

...these are my notes

C

Simple Multi-threaded web server written in C using pthreads

This Multi-threaded web server takes advantage of the posix thread library to enable it it serve multiple files at the same time. ¬†Compile using gcc and run on a linux server. // Multi-Threaded web server using posix pthreads // BK Turley 2011 //this simple web server is capible of serving simple html, jpg, gif & text files //—– Include files ——————————————————— #include <stdio.h> // for printf() #include <stdlib.h> // for exit() #include <string.h> // for strcpy(),strerror() and strlen() #include <fcntl.h> // for file i/o constants #include <sys/stat.h> // for file i/o constants #include <errno.h> /* FOR BSD UNIX/LINUX —————————————————- */ […]

C Code

Simple Example of Multithreading in C Linux

This simple example demonstrates the use of multithreading in the linux environment. This little piece of C code has two threads, a producer thread and a consumer thread. The producer thread generates 600 random numbers, which are passed one at a time to a consumer thread via shared memory. Both threads sum all of the random numbers. The fact that both the producer and consumer have the same sum is proof that the thread are communicating together correctly. /* * File: CS314_P01_BKT.c * Author: BK Turley * */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <sys/sem.h> […]

C++ code

Binary Search Tree implemented. C++

This is my personal implementation of a binary search tree. My tree uses iteration instead of recursion for its insertion, deletion and searches for faster execution because function stack overhead is avoided. Recursion is still used for tree deletion because I didn’t want to implement a stack for the traversal of the tree which is required for deletion. // SearchableADT test driver // Copyright (C) 2011 Kyle Turley // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, […]

Code

convert integer to any base C++

this function is capable of converting integers to any base format 2-16. this includes binary, octal, and hexadecimal. adding larger bases is as simple as lengthening the alpha string. //this recursive base converter is valid for base 2~16 void toBase(int num, int base) { string alpha="0123456789ABCDEF"; if (n > 0) { toBase(num/base,base); cout << alpha[num%base]; } }

Code

Some Great Examples of recursion C++

This little program demonstrates the recursion technique in three different settings.¬† It includes recursive algorithms to search an array, reverse a number, and find the greatest common divisor of two numbers. // Boyd Turley #include <iostream> #include <string> #include <fstream> #include <iomanip> //required to use setw() #include <cstdio> using namespace System; using namespace std; ///////////////////////////////////// Globals const int TABLE_ROWS = 30; const int TABLE_COLS = 20; int table[TABLE_COLS][TABLE_ROWS]; int grid[599]; //////////////////////////////////// FXN Defs. bool posWhole(int checkme); void NumReverse(int reverseme); void setOrder(int num1, int num2); int GCD(int num1, int num2); void gridSearch(); ///////////////////////////////////////////////////////////////////////////////////////// MAIN int main(array<System::String ^> ^args) { char thechoice […]

Code

Dynamic Array Example C++

//this is an example of an array of dynamic memory #include <iostream> using namespace std; void main() { typedef int* IntPtr; IntPtr intList; int listSize; cout << "How big is the list? "; cin >> listSize; intList = new int[listSize]; for (int i = 0; i < listSize; i++) { intList[i] = i; cout << intList[i] << ‘ ‘ << &intList[i] << endl; } cout << endl; delete [] intList; //ALLWAYS remember to match new statements with delete statements system("pause"); }

C++ code Code

A realistic C++ line counter

This program asks the user for a c++ source file. It displays the file’s linecount to the screen. Program exits on invalid input. This sourcefile is 90 lines of code(according to itself). Each of the following counts as one line of code: Preprocessor directives if() while() do..while() switch() non-repeating semicolons #include <iostream> #include <fstream> #include <string> using namespace std; // accepts a valid C++ filename, returns a C++ linecount. Prints a error and exits program on invalid input. int loc(string filename); int main() { string filename; cout << "Enter a cpp filename to linecount " << endl; cin >> filename; […]

Code Verilog

16 bit ALU Verilog design

// 4 channel, 1 bit mux // BK Turley `timescale 1ns/100ps module mux_4to1(out, sel, in0, in1, in2, in3); output out; input [1:0] sel; input in0; input in1; input in2; input in3; reg out; always @( sel or in0 or in1 or in2 or in3) case (sel) 2’b00 : out <= in0; 2’b01 : out <= in1; 2’b10 : out <= in2; 2’b11 : out <= in3; default : out <= in0; endcase endmodule