|
IT-Programmet,
Tema 1 i termin 4:
TTIT61 Processprogrammering och Operativ System/Concurrent Programming and Operating Systems/Lab 00: Introduction to C programming1. Hello, world. [10 min]Everytime you start to work with a new programming language, it is tradition to make the "Hello, world" program. Create it, compile it and run it.2. debug this [20 min]First try to understand the program below and spot the bug, but don't fix it. (It's ok if you can't find it.)Run the program in ddd to find the row where the segmentation fault occurs. You must first compile it with the -g flag for this to work.
#include <stdio.h> N.B. This is a silly and not very pretty program.
3. Create a linked list of integers. [50 min]Create a linked list with the following functions:
void append(struct list_item *first, int x); /* puts x at the end of the list */
Hint1: You need to use
Hint2: Implementing the list will be easier if you make
4. Browsing the code. [10 min]Using tags with emacs. Install pintos using the instructions from Lab0. Change to your new${YOURPATH}/pintos/src and run:
find . -name \*.c | xargs etags -
find . -name \*.h | xargs etags --append -
This created an index of structs and functions in a new file named
TAGS. Now let's find where the pintos semaphore is. Start emacs and
press meta-. (hold meta and press dot). Type the keyword you wish
to look for, "semaphore" in this case, and press enter. Press enter
again to confirm the path to your TAGS file, and there you are!
Sometimes when you want to know where a file is in the hierarchy this command is useful:
find ${YOURPATH}/pintos/src |grep filename
Try find the file list.c. Open it to see a more
complicated linked list implementation than the one you just
created.
Now imagine that you want to find all files where this list is used, for this you can use the following command:
find ${YOURPATH}/pintos/src -type f -print |xargs grep list_init
Next Laboratory workLaboratory Assignment 1 in which you will learn the basics of synchronization |
Sidansvarig: Sergiu Rafiliu
Senast uppdaterad: 2011-09-12
