成a人片国产精品_色悠悠久久综合_国产精品美女久久久久久2018_日韩精品一区二区三区中文精品_欧美亚洲国产一区在线观看网站_中文字幕一区在线_粉嫩一区二区三区在线看_国产亚洲欧洲997久久综合_不卡一区在线观看_亚洲欧美在线aaa_久久99精品国产_欧美卡1卡2卡_国产精品你懂的_日韩精品91亚洲二区在线观看_国内一区二区视频_91丨国产丨九色丨pron

代寫CSIE3310、代做c++/Python編程

時間:2024-03-21  來源:  作者: 我要糾錯



Machine Problem 1 - Thread Package
CSIE3310 - Operating Systems
National Taiwan University
Total Points: 100
Release Date: March 5
Due Date: March 19, 23:59:00
TA e-mail: ntuos@googlegroups.com
TA hours: Wed. & Thu. 10:00-12:00 before the due date, CSIE Building R428
Contents
1 Summary 1
2 Environment Setup 2
3 Part 1 (60 points) 2
3.1 Function Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.2 Sample Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
4 Part 2 (40 points) 4
4.1 Function Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.2 Reminders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4.3 Sample Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5 Run Public Test Cases 5
6 Submission and Grading 5
6.1 Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
6.2 Folder Structure after Unzip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
6.3 Grading Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
7 Appendix 6
1 Summary
In this MP, you’ll try to implement a user-level thread package with the help of setjmp and longjmp. The
threads explicitly yield when they no longer require CPU time. When a thread yields or exits, the next thread
should run. The thread can assign additional tasks to other threads, including itself. There are two parts in
this MP. In the first part, you’ll need to implement the following functions:
• thread add runqueue
• thread yield
• dispatch
• schedule
• thread exit
• thread start threading
In the second part, you’ll need to implement the following functions:
• thread assign task
The following function has been implemented for you:
• thread create
Each thread should be represented by a struct thread that contains, at a minimum, a function pointer to the
thread’s function and a pointer of type void * as the function parameters. The function of the thread will take
the void * as its argument when executed. The struct should include a pointer to its stack and some jmp buf
to store it’s current state when thread yield is called. It should be enough to use only setjmp and longjmp
to save and restore the context of a thread.
2 Environment Setup
1. Download the MP1.zip from NTUCOOL, unzip it, and enter it.
$ unzip MP1.zip
$ cd mp1
2. Pull Docker image from Docker Hub.
$ docker pull ntuos/mp1
3. Use docker run to start the process in a container and allocate a TTY for the container process.
$ docker run -it -v $(pwd)/xv6:/home ntuos/mp1
4. Execute xv6
$ make qemu
5. You will use the skeleton of threads.h and threads.c provided in xv6/user folder. Make sure you are
familiar with the concept of stack frame and stack pointer taught in System Programming. It is also
recommended to checkout the appendix given.
3 Part 1 (60 points)
3.1 Function Description
1. struct thread *thread create(void (*f)(void *), void *arg): This function creates a new thread
and allocates the space in stack to the thread. Note, if you would like to allocate a new stack for the
thread, it is important that the address of the stack pointer should be divisible by 8. The function returns
the initialized structure. If you want to use your own template for creating thread, make sure it works
for the provided test cases.
2. void thread add runqueue(struct thread *t): This function adds an initialized struct thread to
the runqueue. To implement the scheduling functionality, you’ll need to maintain a circular linked list
of struct thread. You should implement that by maintaining the next and previous field in struct
thread which always points to the next to-be-executed thread and the previously executed thread respectively. You should also maintain the static variable struct thread *current thread that always
points to the currently executed thread. Note: Please insert the new thread at the end of the runqueue,
i.e. the newly inserted thread should be current thread->previous.
3. void thread yield(void): This function suspends the current thread by saving its context to the
jmp buf in struct thread using setjmp. The setjmp in xv6 is provided to you, therefore you only need
to add #include "user/setjmp.h" to your code. After saving the context, you should call schedule()
to determine which thread to run next and then call dispatch() to execute the new thread. If the thread
is resumed later, thread yield() should return to the calling place in the function.
4. void dispatch(void): This function executes a thread which decided by schedule(). In case the thread
has never run before, you may need to do some initialization such as moving the stack pointer sp to the
allocated stack of the thread. The stack pointer sp could be accessed and modified using setjmp and
longjmp. Please take a look at setjmp.h to understand where the sp is stored in jmp buf. If the thread
was executed before, restoring the context with longjmp is enough. In case the thread’s function just
returns, the thread needs to be removed from the runqueue and the next one has to be dispatched. The
easiest way to do this is to call thread exit().
5. void schedule(void): This function will decide which thread to run next. It is actually trivial, since you
will just run the next thread in the circular linked list of threads. You can simply change current thread
to the next field of current thread.
6. void thread exit(void): This function removes the calling thread from the runqueue, frees its stack
and the struct thread, updates current thread with the next to-be-executed thread in the runqueue
and calls dispatch().
Furthermore, think about what happens when the last thread exits (should return to the main function
by some means).
7. void thread start threading(void): This function will be called by the main function after some
thread is added to the runqueue. It should return only if all threads have exited.
3.2 Sample Output
The output of mp1-part1-0 should look like the following.
$ mp1-part1-0
mp1-part1-0
thread 1: 100
thread 2: 0
thread 3: 10000
thread 1: 101
thread 2: 1
thread 3: 10001
thread 1: 102
thread 2: 2
thread 3: 10002
thread 1: 103
thread 2: 3
thread 3: 10003
thread 1: 104
thread 2: 4
thread 3: 10004
thread 1: 105
thread 2: 5
thread 1: 106
thread 2: 6
thread 1: 107
thread 2: 7
thread 1: 108
thread 2: 8
thread 1: 109
thread 2: 9
exited
4 Part 2 (40 points)
In this part, you are required to implement an additional function thread assign task. This function enables
each thread to manage multiple tasks, with the most recently assigned task being executed first. Note that,
child threads should not inherit tasks from their parent when they are created.
4.1 Function Description
1. void thread assign task(struct thread *t, void (*f)(void *), void *arg): This function assigns a task to the thread t. The second argument, f, is a pointer to the task function, while the third
argument, arg, represents the argument of f. If t has unfinished tasks, the most recently assigned task
will be executed first when t is resumed later. The execution of the original thread function must wait
until all tasks are finished. Note that, this function only assigns tasks and does not trigger any context
switch.
In order to complete this part, you need to modify the following functions:
1. void thread yield(void): Because this function can also be called in the task function, you should save
the context in different jmp bufs according to whether the thread is executing the task function or not.
Specifically, if this function is called in the thread function, you can save the context just like in part 1.
If this function is called in the task function, you should save the context in another jmp buf to prevent
from discarding the context of the thread function.
2. void dispatch(void): If a task is assigned, this function should execute the most recently assigned task
function. If this function has never run before, you may need to do some initialization. If this function
was executed before, restoring the context with longjmp is sufficient. In case this task function just
returns, the thread should execute the next task function. The process follows the same approach as with
the previous task function. Surely, It is possible for a task to be assigned before the thread executes its
thread function.
Feel free to make more modification, such as adding properties in struct thread, designing new structure
for encapsulating task-related logic, etc. The only requirement is that all defined function should work as
described above.
4.2 Reminders
1. When creating a new thread in thread create, ensure that the new thread has no assigned tasks initially.
2. The parameter struct thread *t in thread assign task must exist and not have exited yet.
3. Tasks are executed in Last-Come-First-Serve (LCFS) order. That is, if a thread returns from a task
function and there are unfinished tasks, the most recently assigned task will be executed next.
4. While you are encouraged to add properties in struct thread, modifying the existing properties is not
allowed.
5. The task function may call thread create, thread add runqueue, thread yield, thread exit, or
thread assign task.
6. The memory space allocated to each thread by thread create is sufficient to execute task functions in
all test cases.
7. In all test cases, a thread may have at most 20 unfinished tasks at any moment.
8. If you intend to use global variables in threads.h, threads.c, or your test files, it is recommended to
add the static keyword to prevent unexpected situations.
4.3 Sample Output
The output of mp1-part2-0 should look like the following.
$ mp1-part2-0
mp1-part2-0
thread 1: 100
task 2: 101
thread 2: 0
thread 1: 101
thread 2: 1
thread 1: 102
task 2: 103
thread 1: 103
thread 2: 2
thread 1: 104
task 2: 105
thread 2: 3
thread 1: 105
thread 2: 4
exited
5 Run Public Test Cases
You can get 35 points (100 points in total) if you pass all public test cases. You can judge the code by running
the following command in the docker container (not in xv6; this should run in the same place as make qemu).
Note that you should only modify xv6/user/thread.c and xv6/user/thread.h. We do not guarantee that
you can get the public points from us if you modify other files to pass all test cases during local testing.
$ make grade
If you successfully pass all the public test cases, the output should be similar to the one below.
== Test thread package with public testcase part1-0 (10%) ==
thread package with public testcase part1-0: OK (16.8s)
== Test thread package with public testcase part1-1 (10%) ==
thread package with public testcase part1-1: OK (1.3s)
== Test thread package with public testcase part2-0 (5%) ==
thread package with public testcase part2-0: OK (0.8s)
== Test thread package with public testcase part2-1 (5%) ==
thread package with public testcase part2-1: OK (0.9s)
== Test thread package with public testcase part2-2 (5%) ==
thread package with public testcase part2-2: OK (1.0s)
Score: 35/35
If you want to know the details about the test cases, please check xv6/grade-mp1, xv6/user/mp1-part1-0.c,
xv6/user/mp1-part1-1.c, xv6/user/mp1-part2-0.c, xv6/user/mp1-part2-1.c and xv6/user/mp1-part2-2.c.
6 Submission and Grading
6.1 Source Code
Run the command below to pack your code into a zip named in your lowercase student ID, for example,
r11922088.zip. Upload the zip file to NTUCOOL.
$ make STUDENT_ID=<student_id> zip # set your ID here
Please ensure that your student ID is in lowercase letters. E.g., it should be r11922088 instead of
R11922088. Besides, make sure your xv6 can be compiled by make qemu.
6.2 Folder Structure after Unzip
We will unzip your submission using unzip command. The unzipped folder structure looks like this.
<student_id>
|
+-- threads.c
|
+-- threads.h
6.3 Grading Policy
• There are 2 public test cases and 4 private test cases in Part 1.
– Public test cases (20%): mp1-part1-0 and mp1-part1-1. 10% each.
– Private test cases (40%): 10% each.
• There are 3 public test cases and 4 private test cases in Part 2.
– Public test cases (15%): mp1-part2-0, mp1-part2-1 and mp1-part2-2. 5% each.
– Private test cases (25%): 5%, 5%, 7.5%, 7.5%.
• You will get 0 if we cannot compile your submission.
• You will be deducted 10 points if we cannot unzip your file through the command line using the unzip
command in Linux.
• You will be deducted 10 points if the folder structure is wrong. Using uppercase in the <student id> is
also a type of wrong folder structure.
• If your submission is late for n days, your score will be max(raw score − 20 × ⌈n⌉, 0) points. Note that
you will not get any points if ⌈n⌉ >= 5.
• Our grading library has a timeout mechanism so that we can handle the submission that will run forever.
Currently, the execution time limit is set to 240 seconds. We may extend the execution time limit if we
find that such a time limit is not sufficient for programs written correctly. That is, you do not have to
worry about the time limit.
• You can submit your work as many times as you want, but only the last submission will be graded.
Previous submissions will be ignored.
• The grading will be done on a Linux server.
請加QQ:99515681  郵箱:99515681@qq.com   WX:codehelp 

標(biāo)簽:

掃一掃在手機打開當(dāng)前頁
  • 上一篇:代寫CPS 1032、Java/Python程序代做
  • 下一篇:代做Lab 2: Time Series Prediction with GP
  • 無相關(guān)信息
    昆明生活資訊

    昆明圖文信息
    蝴蝶泉(4A)-大理旅游
    蝴蝶泉(4A)-大理旅游
    油炸竹蟲
    油炸竹蟲
    酸筍煮魚(雞)
    酸筍煮魚(雞)
    竹筒飯
    竹筒飯
    香茅草烤魚
    香茅草烤魚
    檸檬烤魚
    檸檬烤魚
    昆明西山國家級風(fēng)景名勝區(qū)
    昆明西山國家級風(fēng)景名勝區(qū)
    昆明旅游索道攻略
    昆明旅游索道攻略
  • NBA直播 短信驗證碼平臺 幣安官網(wǎng)下載 歐冠直播 WPS下載

    關(guān)于我們 | 打賞支持 | 廣告服務(wù) | 聯(lián)系我們 | 網(wǎng)站地圖 | 免責(zé)聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 kmw.cc Inc. All Rights Reserved. 昆明網(wǎng) 版權(quán)所有
    ICP備06013414號-3 公安備 42010502001045

    成a人片国产精品_色悠悠久久综合_国产精品美女久久久久久2018_日韩精品一区二区三区中文精品_欧美亚洲国产一区在线观看网站_中文字幕一区在线_粉嫩一区二区三区在线看_国产亚洲欧洲997久久综合_不卡一区在线观看_亚洲欧美在线aaa_久久99精品国产_欧美卡1卡2卡_国产精品你懂的_日韩精品91亚洲二区在线观看_国内一区二区视频_91丨国产丨九色丨pron
    国产盗摄一区二区三区| 国产精品18久久久久久vr| 亚洲成在线观看| 国产一区二区在线观看免费| 在线亚洲高清视频| 欧美经典一区二区| 三级一区在线视频先锋| 99久久免费视频.com| 久久午夜色播影院免费高清 | 国产精品国产三级国产专播品爱网| 五月婷婷欧美视频| 一本一道久久a久久精品 | 精品免费99久久| 亚洲综合一区二区| 欧美a级理论片| 在线视频你懂得一区二区三区| 国产欧美日韩亚州综合 | 欧美第一区第二区| 亚洲乱码中文字幕综合| 国产成人亚洲综合a∨婷婷图片| 欧美群妇大交群的观看方式| 一区二区三区四区视频精品免费| 成人午夜在线免费| 久久综合99re88久久爱| 老司机精品视频导航| 制服丝袜国产精品| 午夜免费欧美电影| 精品视频在线免费| 亚洲黄色免费电影| 国产在线不卡一卡二卡三卡四卡| 6080午夜不卡| 日韩国产欧美在线播放| 欧美日韩精品高清| 国产精品美女久久久久久| 国产成人精品一区二区三区网站观看| 欧美一区二区视频在线观看2022| 性欧美疯狂xxxxbbbb| 欧美性大战久久久久久久蜜臀 | 亚洲免费看黄网站| 99综合影院在线| 中文字幕免费不卡在线| 国产精品888| 国产色综合久久| 国产成人综合精品三级| 久久久久久久久岛国免费| 国产精品一区二区三区99| 国产网红主播福利一区二区| 国产成人亚洲精品青草天美| 国产日韩高清在线| 懂色av中文字幕一区二区三区| 中文在线一区二区 | 色综合久久久久| 亚洲天堂2016| 一本色道久久综合狠狠躁的推荐 | 最新国产の精品合集bt伙计| 91麻豆视频网站| 亚洲精品一二三| 欧美在线不卡视频| 午夜成人免费电影| 91麻豆精品国产91久久久久| 美脚の诱脚舐め脚责91| 精品久久久三级丝袜| 国产精品一级二级三级| 中文一区二区完整视频在线观看| 国产高清久久久| 中文字幕第一页久久| 99久久国产免费看| 伊人婷婷欧美激情| 欧美二区三区的天堂| 麻豆精品一区二区三区| 久久久99精品免费观看| 成人黄色777网| 中文字幕中文在线不卡住| 在线一区二区观看| 日韩成人午夜电影| 国产亚洲一区二区三区四区| 色综合久久综合网欧美综合网 | 国产91在线|亚洲| 一区二区在线免费| 欧美一区二区免费观在线| 国产成人av影院| 一区二区三区在线视频播放| 欧美一区二区大片| 成人精品gif动图一区| 亚洲不卡一区二区三区| 久久综合九色欧美综合狠狠 | 日韩亚洲欧美一区| 成人永久看片免费视频天堂| 一区二区三区四区不卡在线| 精品日韩在线一区| av亚洲精华国产精华| 五月婷婷久久综合| 国产欧美一区二区在线| 91亚洲精品乱码久久久久久蜜桃 | 青青草国产成人99久久| 国产亚洲美州欧州综合国| 成人不卡免费av| 日日摸夜夜添夜夜添国产精品| 精品电影一区二区| 成人教育av在线| 亚洲一二三四在线| 欧美日韩电影在线播放| 成人一区二区三区| 亚洲影视在线播放| 国产黄色成人av| 国产精品久久久久一区二区三区共| 在线视频观看一区| 久久久不卡网国产精品二区| 91久久精品一区二区三区| 蜜臀av一级做a爰片久久| 国产欧美精品在线观看| 欧美色电影在线| 精品一二三四区| 最新国产成人在线观看| xnxx国产精品| 一本久久精品一区二区| 蜜臀av一区二区在线免费观看| 中文字幕av在线一区二区三区| 欧美日韩国产高清一区二区| 狠狠色丁香婷婷综合| 亚洲精品高清在线| 精品国产精品一区二区夜夜嗨| 91在线看国产| 五月综合激情网| 亚洲欧美色一区| 亚洲精品一区在线观看| 色诱亚洲精品久久久久久| 久久精品国产亚洲高清剧情介绍| ㊣最新国产の精品bt伙计久久| 欧美一区二区三区系列电影| 91福利视频久久久久| 国内久久精品视频| 亚洲精品视频免费看| 欧美精品一区二区在线播放| 91国产免费观看| 国产成人免费高清| 亚洲国产欧美另类丝袜| 亚洲日本成人在线观看| 亚洲欧洲日产国产综合网| 3d动漫精品啪啪一区二区竹菊| 国产·精品毛片| 青青草97国产精品免费观看 | 一级中文字幕一区二区| 欧美精品一区二区三区在线| 欧美日韩一区不卡| 成人av免费观看| 久久99精品久久久久久| 一个色综合av| 国产精品欧美极品| 国产欧美精品一区二区三区四区| 91精品国产综合久久久蜜臀图片| 亚洲一区二区欧美日韩| 亚洲乱码国产乱码精品精98午夜| 久久久久久久久99精品| 欧美一区中文字幕| 在线一区二区观看| 成人动漫av在线| 国产一区二区三区观看| 国产一区视频网站| 男女男精品视频| 亚洲高清免费观看| 亚洲欧美日韩国产综合| 欧美激情综合五月色丁香| 日本一区二区成人| 精品国产髙清在线看国产毛片| 欧美久久久久中文字幕| 色94色欧美sute亚洲13| 不卡视频在线观看| 蜜臀av性久久久久av蜜臀妖精| 日本在线观看不卡视频| 亚洲一区二区三区四区的| 最新成人av在线| 国产精品高潮久久久久无| 国产亲近乱来精品视频| 国产精品免费视频一区| 国产日韩v精品一区二区| 精品国产99国产精品| 日韩欧美国产一区在线观看| 欧美电影一区二区三区| 欧美亚洲另类激情小说| 欧美日韩高清影院| 欧美日韩国产免费| 欧美无砖专区一中文字| 在线一区二区三区| 在线观看日韩毛片| 91精品欧美福利在线观看| 69堂成人精品免费视频| 欧美蜜桃一区二区三区| 在线91免费看| 这里只有精品视频在线观看| 日韩亚洲欧美在线| 精品乱人伦一区二区三区| 精品欧美黑人一区二区三区| 精品欧美久久久| 久久蜜桃一区二区| 成人午夜在线视频| 成人精品小蝌蚪| 99在线精品视频| 国产成人在线视频网站| 国产精品18久久久|