All non-programming, written problems in this assignment are to be done by yourself. Group collaboration is permitted only on the kernel programming problems. All homework submissions (both individual and group) are to be made via Git.
The Git repository you will use for the individual, written portion of this assignment can cloned using:
git clone gitosis@os1.cs.columbia.edu:UNI/hmwk2.git
(replace UNI with your own UNI). This repository will be accessible only by you, and you will use the same SSH public/private key-pair used for homework 1.
Exercise numbers refer to the course textbook,
Operating System Concepts Essentials. Each problem is worth 3 points.
Group programming problems are to be done in your assigned groups. The Git repository your entire group will use to submit the group programming problems can be cloned using: git clone gitosis@os1.cs.columbia.edu:TEAM/hmwk2.git (Replace TEAM with the name of your team, e.g. team1). This repository will be accessible to all members of your team, and all team members are expected to commit (local) and push (update the server) changes / contributions to the repository equally. You should become familiar with team-based shared repository Git commands such as git-pull, git-merge, git-fetch.
All team members should make at least five commits to the team's Git repository. The point is to make incremental changes and use an iterative development cycle. Follow the Linux kernel coding style and check your commits with the checkpatch.pl script. Errors from the script in your submission will cause a deduction of points.
The kernel programming for this assignment will be done using a custom
Android device emulator. As a part of this
assignment, you will be experimenting with the Android platform and gaining familiarity
with the development environment. Subsequent assignments will involve using the
Android SDK and devtools to modify a Google
Nexus 7. The Android platform can run on many different
architectures, but the specific platform we will be targetting is the ARM cpu family.
The Android emulator is built on a system called QEMU
which emulates an ARMv5 processor (specifically the ARM926E).
Because the target CPU is (most likely) different from the CPU running in your
personal computer, you will have to cross-compile any software, including the linux
kernel, to run on the different platform. The relevant Android/ARM SDK files have
been pre-installed in a new virtual machine available for download
here.
You should run ~/prep_vm.sh on the VM once after downloading it. The username and password information is the same as the previous VM
you used for homework 1.
In order to work with the
emulator, you will need an X11 display. This can be accomplished in
one of three ways:
int ptree(struct prinfo *buf, int *nr);You should define struct prinfo as:
struct prinfo {
long state; /* current state of process */
pid_t pid; /* process id */
pid_t parent_pid; /* process id of parent */
pid_t first_child_pid; /* pid of youngest child */
pid_t next_sibling_pid; /* pid of older sibling */
long uid; /* user id of process owner */
char comm[64]; /* name of program executed */
};
in include/linux/prinfo.h as part of your solution.
read_lock(&tasklist_lock); ... ... read_unlock(&tasklist_lock);
printf(/* correct number of \t */);
printf("%s,%d,%ld,%d,%d,%d,%d\n", p.comm, p.pid, p.state,
p.parent_pid, p.first_child_pid, p.next_sibling_pid, p.uid);
init,1,1,0,33,0,0 /system/bin/sh,27,1,1,0,28,0 /system/bin/vold,28,1,1,0,29,0 ... zygote,33,1,1,61,0,100 system_server,61,1,33,0,129,501 com.android.phone,129,1,33,0,130,1000 com.android.settings,130,0,33,0,131,1000 ... kthreadd,2,1,0,3,0,0 ksoftirqd/0,3,1,2,0,4,0 events/0,4,1,2,0,5,0 khelper,5,1,2,0,6,0 ...
# Set this to the name of your program
TARGET = output_name
# Edit this variable to point to all
# of your sources files (make sure
# to put a complete relative path)
SOURCES = mysrc1.c \
mysrc2.c
# -----------------------------------------------
#
# Don't touch things below here unless
# you know what you're doing :-)
#
OBJECTS = $(SOURCES:%.c=%.c.o)
INCLUDE = -I.
CFLAGS = -g -O2 -Wall $(INCLUDE) -static
LDFLAGS = -static
CC = arm-none-linux-gnueabi-gcc
LD = arm-none-linux-gnueabi-gcc
default: $(SOURCES) $(TARGET)
$(TARGET): $(OBJECTS)
@echo [Arm-LD] $@
@$(LD) $(LDFLAGS) $(OBJECTS) -o $@
%.c.o: %.c
@echo [Arm-CC] $<...
@$(CC) -c $(CFLAGS) $< -o $@
clean: .PHONY
@echo [CLEAN]
@rm -f $(OBJECTS) $(TARGET)
.PHONY: