Skip to content

Commit

Permalink
Updating references
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuvy2 committed Jan 13, 2020
1 parent a6cdc3d commit a620438
Show file tree
Hide file tree
Showing 48 changed files with 724 additions and 1,513 deletions.
1 change: 0 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Lawrence Angrave <[email protected]>
Bhuvan Venkatesh <[email protected]>
joebenassi <[email protected]>
jakebailey <[email protected]>
Ebrahim Byagowi <[email protected]>
Expand Down
1 change: 0 additions & 1 deletion _images/duck-alpha-cropped.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion _images/epub_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion _images/pdf_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions _scripts/gen_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ def __init__(self, bare_name, tex_name, meta, outdir):
This book is an introduction to programming in C, and system programming (processes, threads, synchronization, networking and more!). We assume you've already had some programming experience, in an earlier computer science course. If you have any typos to report or content to request, feel free to file an issue at the link above. Happy Reading!
-- Bhuvy
<h3 id="one-big-pdf" class="title-text"><a href="https://github.com/illinois-cs241/coursebook/tree/pdf_deploy/main.pdf" alt="PDF Version" class="wiki-link">One Big PDF<img src="https://raw.githubusercontent.com/illinois-cs241/coursebook/master/_images/pdf_icon.png" style="margin-left: 10px;" width="auto" height="50px"> </a></h3>
<h3 id="one-big-epub" class="title-text"><a href="https://github.com/illinois-cs241/coursebook/tree/epub_deploy/main.epub" alt="Epub Versions" class="wiki-link">One Big EPUB<img src="https://raw.githubusercontent.com/illinois-cs241/coursebook/master/_images/epub_icon.png" style="margin-left: 10px;" width="auto" height="50px"> </a></h3>
Expand Down
6 changes: 3 additions & 3 deletions background/background.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\chapter{Background}

\epigraph{Sometimes the journey of a thousand steps begins by learning to walk}{Bhuvy}
\epigraph{Sometimes the journey of a thousand steps begins by learning to walk}{}

\section{Systems Architecture}

Expand Down Expand Up @@ -245,7 +245,7 @@ \subsection{Editors}

At that point, the files on your VM are synced with the files on your machine and edits can be made and will be synced.

At the time of writing, Bhuvy (That's me!) likes to use spacemacs \url{http://spacemacs.org/} which marries both vim and emacs and both of their difficulties.
At the time of writing, an author likes to use spacemacs \url{http://spacemacs.org/} which marries both vim and emacs and both of their difficulties.
I'll give my soapbox for why I like it, but be warned that if you are starting from absolutely no vim or emacs experience the learning curve along with this course may be too much.
\begin{enumerate}
\item Extensible. Spacemacs has a clean design written in lisp. There are 100s of packages ready to be installed by editing your spacemacs config and reloading that do everything from syntax checking, automatic static analyzing, etc.
Expand Down Expand Up @@ -715,7 +715,7 @@ \subsection{strace and ltrace}

\begin{lstlisting}[language=bash]
$ strace -e trace=read,write -P README.md head README.md
strace: Requested path 'README.md' resolved into '/mnt/c/Users/bhuvy/personal/libds/README.md'
strace: Requested path 'README.md' resolved into '/mnt/c/Users/user/personal/libds/README.md'
read(3, "# C Datastructures\n\n[![Build Sta"..., 8192) = 1250

\end{lstlisting}
Expand Down
1 change: 0 additions & 1 deletion deadlock/drawings/deadlock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion deadlock/drawings/dining.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion deadlock/drawings/dining_arbitrator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion deadlock/drawings/dining_livelock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion deadlock/drawings/dining_naive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion deadlock/drawings/dining_partial.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion deadlock/drawings/dining_stalling.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion deadlock/drawings/rag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion filesystems/filesystems.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\chapter{Filesystems}

\epigraph{\keyword{/home} is where the heart is}{Bhuvy}
\epigraph{\keyword{/home} is where the heart is}{}

Filesystems are important because they allow you to persist data after a computer is shut down, crashes, or has memory corruption.
Back in the day, filesystems were expensive to use.
Expand Down
34 changes: 17 additions & 17 deletions introc/c_memory_model.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ \subsection{Structs}
unsigned int phone;
};

struct contact bhuvan;
struct contact person;
\end{lstlisting}

We will often use the following typedef, so we can write use the struct name as the full type.

\begin{lstlisting}[language=C]
typedef struct contact contact;
contact bhuvan;
contact person;

typedef struct optional_name {
...
Expand All @@ -32,10 +32,10 @@ \subsection{Structs}
If you compile the code without any optimizations and reordering, you can expect the addresses of each of the variables to look like this.

\begin{lstlisting}[language=C]
&bhuvan // 0x100
&bhuvan.firstname // 0x100 = 0x100+0x00
&bhuvan.lastname // 0x114 = 0x100+0x14
&bhuvan.phone // 0x128 = 0x100+0x28
&person // 0x100
&person.firstname // 0x100 = 0x100+0x00
&person.lastname // 0x114 = 0x100+0x14
&person.phone // 0x128 = 0x100+0x28
\end{lstlisting}

All your compiler does is say "reserve this much space".
Expand All @@ -52,12 +52,12 @@ \subsection{Structs}
char c_str[0];
} string;

const char* to_convert = "bhuvan";
const char* to_convert = "person";
int length = strlen(to_convert);

// Let's convert to a c string
string* bhuvan_name;
bhuvan_name = malloc(sizeof(string) + length+1);
string* person;
person = malloc(sizeof(string) + length+1);
\end{lstlisting}

Currently, our memory looks like the following image.
Expand All @@ -76,7 +76,7 @@ \subsection{Structs}
This means that the least significant byte is last.

\begin{lstlisting}[language=C]
bhuvan_name->length = length;
person->length = length;
\end{lstlisting}

\begin{figure}[H]
Expand All @@ -88,19 +88,19 @@ \subsection{Structs}
Now, we can write a string to the end of our struct with the following call.

\begin{minted}{C}
strcpy(bhuvan_name->c_str, to_convert);
strcpy(person->c_str, to_convert);
\end{minted}

\begin{figure}[H]
\centering
\includegraphics[width=.7\textwidth]{introc/drawings/memory_model_full.eps}
\caption{Struct pointing to 11 boxes, 4 filled with 0006, 7 the stirng ``bhuvan''}
\caption{Struct pointing to 11 boxes, 4 filled with 0006, 7 the stirng ``person''}
\end{figure}

We can even do a sanity check to make sure that the strings are equal.

\begin{minted}{C}
strcmp(bhuvan_name->c_str, "bhuvan") == 0 //The strings are equal!
strcmp(person->c_str, "person") == 0 //The strings are equal!
\end{minted}

What that zero length array does is point to the \textbf{end of the struct} this means that the compiler will leave room for all of the elements calculated with respect to their size on the operating system (ints, chars, etc).
Expand Down Expand Up @@ -229,8 +229,8 @@ \subsubsection{String literals are constant}
An example follows.

\begin{lstlisting}[language=C]
char *str1 = "Bhuvy likes books";
char *str2 = "Bhuvy likes books";
char *str1 = "Mark Twain likes books";
char *str2 = "Mark Twain likes books";
\end{lstlisting}

The strings pointed to by \keyword{str1} and \keyword{str2} may actually reside in the same location in memory.
Expand All @@ -239,8 +239,8 @@ \subsubsection{String literals are constant}
These following char arrays reside in different memory locations.

\begin{lstlisting}[language=C]
char arr1[] = "Bhuvy also likes to write";
char arr2[] = "Bhuvy also likes to write";
char arr1[] = "Mark Twain also likes to write";
char arr2[] = "Mark Twain also likes to write";
\end{lstlisting}

Here are some common ways to initialize a string include. Where do they reside in memory?
Expand Down
Loading

0 comments on commit a620438

Please sign in to comment.