程序代写案例-CSE130

University of California Santa Cruz Baskin School of Engineering CSE130 Winter 2021 Lab 1 Copyright © 2017-2021 David C. Harrison. All rights reserved.

CSE130 Winter 2021 : Lab 1

In this assignment you will make minor modifications and minor additions to the source code for the teaching
operating system Pintos.

Specifically, you will implement a more efficient version of the Pintos system call timer_sleep found in
src/devices/timer.c in the Pintos distribution supplied for this lab.

This assignment is worth 5% of your final grade.

Submissions are due NO LATER than 23:59, Sunday January 17 2020 ( > 2 weeks )

Note the elongated time span for this lab is provided so you can become familiar with the CSE130 teaching server
environment and the Pintos teaching operating system. Subsequent labs will be significantly more complex yet
come with only marginally longer deadlines.


Setup

SSH in to one of the CSE130 teaching servers using your CruzID Blue password:

$ ssh @noggin.soe.ucsc.edu ( use Putty http://www.putty.org/ if on Windows )
or $ ssh @nogbad.soe.ucsc.edu
or $ ssh @olaf.soe.ucsc.edu
or $ ssh @thor.soe.ucsc.edu


Authenticate with Kerberos: ( do this every time you log in )

$ kinit ( you will be prompted for your Blue CruzID password )

Authenticate with AFS: ( do this every time you log in )

$ aklog

Create a suitable place to work: ( only do this once )

$ mkdir –p CSE130/Lab1
$ cd CSE130/Lab1

Install the lab environment: ( only do this once )

$ tar xvf /var/classes/CSE130/Winter21/Lab1.tar.gz

Build Pintos:

$ cd ~/CSE130/Lab1/pintos/src/threads ( always work in this directory )
$ make

Also try:

$ make grade ( tells you what grade you will get - see below )



University of California Santa Cruz Baskin School of Engineering CSE130 Winter 2021 Lab 1 Copyright © 2017-2021 David C. Harrison. All rights reserved.

Additional Information

void timer_sleep(int64_t ticks) should suspend execution of the calling thread until time has advanced
by at least the requested number of ticks. Unless the system is otherwise idle, the thread need not wake up after
exactly ticks. It is entirely valid to just put it on the ready queue after they have waited for the right number of
ticks.

Note that the ticks argument is expressed in timer ticks, not in milliseconds or any other unit. Do not change this
data type unless you want lots of the tests to fail.

Separate functions timer_msleep, timer_usleep, and timer_nsleep exist for sleeping a specific number
of milliseconds, microseconds, and nanoseconds respectively, but these will call timer_sleep as appropriate.
You do not need to modify them. 



Accessing the teaching servers’ file systems from your personal computer

You home directories on the teaching servers are UCSC AFS, i.e. they are the same as if you logged into the
UCSC Unix Timeshare. You can edit files in character mode on the console using vi or emacs, but the
recommended editor for CSE130 is Microsoft Visual Studio Code (https://code.visualstudio.com/) which many of
you will already be using.

You will need to install this SFTP ( Secure File Transfer Protocol ) client into VS Code by downloading from here:
https://marketplace.visualstudio.com/items?itemName=suntobright.vscode-sftp

If you have trouble following the instructions in that link, ask a TA for help.


Using the GIT revision control system with Pintos

The CSE130 teaching servers have GIT installed and we highly recommend you use it to track the changes you
make, though this is not required.

However, CSE130 is not a GIT training course, but Google is your friend, so find some beginner tutorials and study
them if you have never used GIT. Also remember you have friends in the shape of your classmates, the TAs, and
your instructor. If you want to know how to setup and use GIT, just ask someone.


Using the GNU Debugger (GDB) with Pintos

The code for this lab is simple and you may find “debugging” it using printf statements and assertions is
sufficient. However, the code for Lab 2 and Lab 3 will be significantly more complex and an appropriately more
sophisticated mechanism for examining your code as it runs will be required.

It is worth learning that mechanism now.

Run a test in debug node (note the new arguments):

$ ../utils/pintos --gdb --gdb-port=NNNN -v -k -T 20 --qemu -- -q run alarm-single

Where NNNN is a four-digit unsigned integer > 1024 defining the network port for the GNU Debugger (GDB) to
listen on; 1234, for example.

If the value of NNNN you choose is already in use, you will get a message similar to the following and should
choose a different value of NNNN.

qemu: -gdb tcp::NNNN: Failed to bind socket: Address already in use


University of California Santa Cruz Baskin School of Engineering CSE130 Winter 2021 Lab 1 Copyright © 2017-2021 David C. Harrison. All rights reserved.

Once you have a unique value of NNNN, in a separate terminal, run GDB for Pintos:

$ ../utils/pintos-gdb build/kernel.o

At the prompt, connect to the running test:

(gdb) target remote localhost:NNNN

GDB will respond:

Remote debugging using localhost:NNNN
0x0000fff0 in ?? ()

From there on in, set breakpoints and step into or over functions as required.

To get the test to run to completion, enter “C” at the (gdb) prompt.

If you don't know how to use GDB, remember Google is your friend. A quick search for “gdb tutorial C” will find
you an abundance of information.

If you get a Pintos GDB session that does not respond to Ctrl-C, run the following command to terminate all
your Pintos sessions:

$ killall pintos


Requirements

Basic:

• You have modified the implementation of void timer_sleep(int64_t ticks) function found in
src/devices/timer.c

• Your modified implementation passes the following functional tests:
o alarm-single

o alarm-multiple

o alarm-simultaneous
o alarm-zero

o alarm-negative

• Your implementation is demonstrably efficient (a non-functional test).



What steps should I take to tackle this?

Study the Secret Sauce from class and come to instructor and TA office hours to ask questions.


How much code will I need to write?

A model solution that satisfies all requirements adds approximately 20 lines of executable code.



University of California Santa Cruz Baskin School of Engineering CSE130 Winter 2021 Lab 1 Copyright © 2017-2021 David C. Harrison. All rights reserved.

Grading scheme

The following aspects will be assessed:

1. (100%) Does it work?

a. Tests pass [5% per test] (25%)
b. Your implementation is demonstrably more efficient than the original (75%)

2. (-100%) Did you give credit where credit is due?

a. Your submission is found to contain code segments copied from on-line resources and you failed to give
clear and unambiguous credit to the original author(s) in your source code (-100%). You will also be
subject to the university academic misconduct procedure as stated in the class academic integrity policy.

b. Your submission is determined to be a copy of a past or present student’s submission (-100%)

c. Your submission is found to contain code segments copied from on-line resources that you did give a
clear an unambiguous credit to in your source code, but the copied code constitutes too significant a
percentage of your submission:

o < 33% copied code No deduction
o 33% to 66% copied code (-50%)
o > 66% copied code (-100%)


What to submit

In a command prompt:

$ cd ~/CSE130/Lab1/pintos/src/threads
$ make submit

This creates a gzipped tar archive named CSE130-Lab1.tar.gz in your home directory.

**** UPLOAD THIS FILE TO THE APPROPRIATE CANVAS ASSIGNMENT ****



Looking ahead

Subsequent labs may require a short report and will have additional assessment criteria, including:

Is it well written?

Marks awarded for:
• Compilation free of errors and/or warnings.
• Clarity
• Modularity

Marks deducted for:
• Failing to do any of the above
• Not following C language good practice (don’t use magic numbers, for example)

I strongly recommend you consider these issues in this lab to get some practice in.


欢迎咨询51作业君
51作业君 51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: ITCSdaixie