代写 C compiler operating system Assignment 1 Released: Feb 12, 2019

Assignment 1 Released: Feb 12, 2019
Due date: Feb 26, 2019, midnight
In this assignment, you will setup your work environment that will be used throughout the semester to implement and test programming assignments.
This assignment has two parts as follows.
Setting up the work environment is the first part of our first Assignment. You have to do it individually.
Briefly, you need to install the virtual box first, then install Ubuntu on top of it, and then install OS161 and Sys161 on top of Ubuntu.
Please follow the instructions below.
Step 1: Assuming you are using Windows operating system, download VirtualBox for Windows
hosts x86/amd64 from https://www.virtualbox.org/wiki/Downloads
Step 2: Download the virtualbox installation manual from HuskyCT and follow the instructions. Step 3: Once you finish installing virtual box, download Ubuntu from the following link.
• Please install this specific version to avoid incompatibility issues with OS161.
• Choose not to update Linux while installing. Please note that this specific version is not
supported anymore, which is fine.
ubuntu-11.10-desktop-i386.iso(this is a hyperlink)
Step 4: Install Ubuntu on top of virtual machine.
Step 5: Once Ubuntu is installed, boot Ubuntu. Now open this doc file inside Ubuntu using your
browser inside Ubuntu. Now, download the following packages inside Ubuntu – gettext_0.18.1.1-3ubuntu1_i386.deb (this is a hyperlink) libncurses5-dev_5.9-1ubuntu5_i386.deb (this is a hyperlink) libtinfo-dev_5.9-1ubuntu5_i386.deb(this is a hyperlink) libunistring0_0.9.3-4_i386.deb(this is a hyperlink) texinfo_4.13a.dfsg.1-8ubuntu1_i386.deb(this is a hyperlink)
Part – I (10 points)

Assuming that these are downloaded in your Ubuntu Download folder, you can install them by executing the following commands –
cd ~/Downloads
sudo dpkg -i ./libtinfo-dev*.deb sudo dpkg -i ./libncurses5-dev*.deb sudo dpkg -i ./libunistring0*.deb sudo dpkg -i ./gettext*.deb
sudo dpkg -i ./texinfo*.deb
Step 6: Now, download the following files inside Ubuntu under your Ubuntu Download folder-
• os161.tar.gz
• os161-binutils.tar.gz
• os161-gcc.tar.gz
• os161-gdb.tar.gz
• sys161.tar.gz
Step 7: Download the instruction file to install OS161 from HuskyCT and follow the instructions downloaded from HuskyCT
Please note that, this assignment takes significant amount of time. Please start immediately.
At this point, you do not need to know the exact semantics of the Linux commands.
Deliverable: Once you are able to start OS161, please take a screenshot and upload on HuskyCT! That’s it!
Part – II (30 points) Purpose: Writing and compiling a C program in Linux
Example:
Let us save this as hello.c
#include main()
{
printf(“Hello, world!\n”);

return 0; }
To compile, type the following in command prompt: gcc -o hello hello.c
The -o option informs the compiler of the desired name for the executable (i.e., runnable) file that it produces. The name used in this example is hello, but it could just as easily be anything else such as hello.exe.
To run, type the following- ./hello
Now as you know how to write and compile a C program, write a C program that can do the followings when you execute your program –
1. Write a program that generates 500 random integers and write them to a file.
2. Write a program that takes the name of the file that you created as input, find the maximum and minimum among all the numbers in the file, and output them.
3. Execute the following code and explain the reason behind the output.
#include int main () {
int i=150;
int *tp;
tp = &i;
printf(“Address of variable i: %x\n”, &i); printf(“Value of *tp variable: %d\n”, *tp );
} return 0;
Hint: Please look up the concept of pointer in C.
What to hand-in:
For 1 and 2, please hand in the code. For 3, please hand in your explanation.