首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
ECSE 427代写、代做c/c++设计程序
项目预算:
开发周期:
发布时间:
要求地区:
ECSE 427/COMP 310 – Operating Systems Assignment 02 – Simple Thread Scheduler
Fall 2023 (version 1) Page 1 10/22/2023
Simple User-Level Thread Scheduler
Check My Courses for Due Date
High-Level Description
In this project, you will develop a simple one-to-many (user-level) threading library with a firstcome, first-served (FCFS) thread scheduler. The library will have two types of executors: one for
running compute tasks and another for input-output (IO) tasks. Each executor is a kernel-level
thread, while the tasks that run are user-level threads. By providing IO tasks their own executor,
compute tasks will not be blocked.
The tasks are C functions, and the library is expected to run the tasks provided in this
assignment. A task is executed by the scheduler until it completes or yields. Once created, each
task is placed in a FCFS ready queue. The provided tasks do not complete and have a while
(true) loop in their bodies. A task can only stop running by yielding or terminating itself. A
yielding task is placed at the end of the ready queue, and the task at the front of the queue is
selected to run next by the scheduler. A newly created task is added to the end of the task ready
queue.
All tasks execute in a single process, which means they share the process' memory. Variables in
the tasks follow C scoping rules. Local variables can be declared in the C function that forms the
"main" of the task, while global variables are accessible from all tasks.
The threading library has two types of executors: one for compute tasks and another for inputoutput (I/O) tasks. For example, a task might need to read or write data to/from a file. This can
be problematic because I/O operations can be blocking, causing the thread to wait until the data
is fetched from the disk. To avoid this, a dedicated executor is used for I/O. The idea is to offload
I/O operations to the I/O executor, allowing the compute executor to continue running without
being blocked.
When a task issues a read request, it is added to a request queue along with the corresponding
task that invoked it. When the response arrives, the task is moved from the wait queue to the task
ready queue, and it will be scheduled to run at a future time. Similar handling applies to write
operations and file opening/closing.
Overall Architecture of the SUT Library
The simple user-level threading (SUT) library being developed in this assignment consists of
several major components. In the following discussion, we assume the presence of one compute
executor (C-EXEC) and one I/O executor (I-EXEC). The C-EXEC is responsible for most
activities in the SUT library, while the I-EXEC handles I/O operations. During initialization of
the SUT library, the first action is to create two kernel-level threads to run C-EXEC and I-EXEC,
respectively.
ECSE 427/COMP 310 – Operating Systems Assignment 02 – Simple Thread Scheduler
Fall 2023 (version 1) Page 2 10/22/2023
Creating a task is done by calling sut_create(). This involves creating a task structure with the
specified C task-main function, stack, and appropriate values filled into the structure. Once the
task structure is created, it is inserted into the task ready queue. The C-EXEC pulls the first task
from the task ready queue and starts executing it. The executing task can take actions that can
alter its state:
1. Yield sut_yield(): This causes the C-EXEC to take control. The user task's context is
saved in a task control block (TCB), and the context of C-EXEC is loaded and started.
The task is then placed at the back of the task ready queue.
2. Exit/Terminate sut_exit(): This causes the C-EXEC to take control, similar to the
previous case. The major difference is that the TCB is not updated and the task is not
inserted back into the task ready queue.
3. Open file sut_open(): This causes the C-EXEC to take control. The user task's context is
saved in a TCB, and the context of C-EXEC is loaded and started, allowing the next user
task to run. The current task is placed at the back of the wait queue. The I-EXEC
executes the function that opens the file, and the result of the open is returned by
sut_open(). This result is an integer, similar to the file descriptor returned by the
operating system. The OS file descriptor can be used, or it can be mapped to another
integer using a mapping table maintained inside the I-EXEC.
4. Read from file sut_read(): This causes the C-EXEC to take control. The user task's
context is saved in a TCB, and the context of C-EXEC is loaded and started, allowing the
next user task to run. The current task is placed at the back of the wait queue. The IEXEC thread is responsible for reading data from the file. The data is read into a memory
area provided by the calling task. It is assumed that the memory buffer is sufficiently
large to hold the data read from the disk.
5. Write to file sut_write(): This causes the C-EXEC to take control, similar to the previous
calls. The I-EXEC thread is responsible for writing data to the file using the file
descriptor (fd) to select the destination file. The contents of the memory buffer passed
into sut_write() are written to the corresponding file.
6. Close file sut_close(): This causes the C-EXEC to take control, similar to the previous
calls. The I-EXEC thread is responsible for closing the file. File closing is done
synchronously in this case.
After the SUT library completes initialization, it starts creating tasks and pushing them into the
task ready queue. Tasks can also be created at runtime by user tasks using the sut_create()
function. The task scheduler may find that there are no tasks to run in the task ready queue. For
example, the only task in the task ready queue may issue a read operation and enter the wait
queue. To reduce CPU utilization, the C-EXEC sleeps briefly using the nanosleep() command (a
sleep of 100 microseconds is appropriate). After the sleep, the C-EXEC checks the task ready
queue again.
The I-EXEC is primarily responsible for processing all I/O functions. The specific
implementation details of I-EXEC operations are left for you to design. Once an I/O operation is
completed for a particular task, the I-EXEC puts the task back into the ready queue so that CEXEC can continue its computations.
ECSE 427/COMP 310 – Operating Systems Assignment 02 – Simple Thread Scheduler
Fall 2023 (version 1) Page 3 10/22/2023
Finally, the library includes one more function to close the entire thread library. The
sut_shutdown() call is responsible for gracefully shutting down the thread library. In this
function, you can include any termination-related actions to cleanly terminate the threading
library. It is important to keep the main thread waiting for the C-EXEC and I-EXEC threads to
finish executing all tasks in the queues before terminating the executors.
The SUT Library API and Usage
The SUT library should provide the following API. To facilitate testing, your library
implementation needs to adhere to this API.
void sut_init();
This function initializes the SUT library. It should be called before making any other API calls.
bool sut_create(sut_task_f fn);
This function creates a task with the given function as its main body. It returns True (1) on
success, and False (0) otherwise.
void sut_yield();
This function allows a running task to yield execution before completing its function.
void sut_exit();
This function terminates the execution of a task. If there are multiple tasks running, calling this
function will only terminate the current task.
• int sut_open(char fname);
Executor (C-EXEC)
Executor (I-EXE
C)
Task Ready
Queue
Wait
Queue
ECSE 427/COMP 310 – Operating Systems Assignment 02 – Simple Thread Scheduler
Fall 2023 (version 1) Page 4 10/22/2023
This function requests the system to open the file specified by the name. It returns a negative
value if the file does not exist, and a non-negative value otherwise.
• void sut_write(int fd, char buf, int size);
This function writes the bytes in the buffer buf to the disk file that is already open. Write errors
are not considered in this call.
void sut_close(int fd);
This function closes the file pointed to by the file descriptor fd.
• *char sut_read(int fd, char buf, int size);
This function is provided with a pre-allocated memory buffer. The calling program is responsible
for allocating the memory. The size parameter specifies the maximum number of bytes that can
be copied into the buffer. If the read operation is successful, a non-NULL value is returned.
Otherwise, it returns NULL.
void sut_shutdown();
This function completely shuts down the executors and terminates the program.
Context Switching and Tasks
To manage user-level thread creation, switching, and more, you can utilize the makecontext()
and swapcontext() functions. The YAUThreads package includes sample code that
demonstrates the usage of user-level context management in Linux. It is important to note that
the provided sample code serves as an illustration of implementing user-level threads and should
not be used as a starting point. However, you have the freedom to reuse relevant portions of the
sample code as needed.
Important Assumptions
Here are some important assumptions you can make in this assignment. If you want to make
additional assumptions, check with the TA-in-charge (Akshay) or the professor.
• There are no interrupts in the user-level thread management to be implemented in this
assignment. A task that starts running only stops for the reasons given in Section 2.
• You can use libraries for creating queues and other data structures – you don’t need to
implement them yourself! We have already provided you with some libraries for
implementing data structures.
Grading
ECSE 427/COMP 310 – Operating Systems Assignment 02 – Simple Thread Scheduler
Fall 2023 (version 1) Page 5 10/22/2023
Your assignment will be evaluated in stages.
1. Simple computing tasks: We will spawn several tasks that perform basic computations,
such as printing messages and yielding. Your task is to demonstrate that you can create
tasks and they can cooperatively switch among them.
2. Tasks that spawn other tasks: In this case, we have some tasks that spawn additional
tasks. A total of 30 tasks, or fewer, will be created. Your goal is to demonstrate that you
can have tasks creating other tasks during runtime.
3. Tasks with read I/O: These tasks involve reading input/output operations.
4. Tasks with read and write I/O: These tasks involve both reading and writing input/output
operations.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!