免费一级欧美片在线观看网站_国产一区再线_欧美日本一区二区高清播放视频_国产99久久精品一区二区300

代寫CSci 4061、c/c++,Java程序代做

時間:2024-04-01  來源:  作者: 我要糾錯



CSci 4061: Introduction to Operating Systems, Spring 2024
Project #3: MultiThreaded Image Matching Server
Instructor: Jon Weissman
Intermediate submission due: 11:59pm (CDT), 4, 4, 2023
Final submission due: 11:59pm (CDT), 4. 12, 2023
1. Background
The purpose of this lab is to construct a multithreaded client and a multithreaded server using
POSIX threads (pthreads) in the C language to learn about thread programming and synchronization
methods. In this project, we will use multithreading to improve the performance of a server that is
programmed to accept an image from the user, match it against a database of known images, and return
the closest matching image. In this programming assignment we will be using the dispatcher-worker
model of threads. There is both concurrency and parallelism at play (the latter if the server is running on a
multicore system). Note: even if threads are dispatched to different cores, they still have direct access to
all of the process memory.
The purpose of this programming assignment is to get you started with thread programming and
synchronization. You need to be familiar with POSIX threads, mutex locks and condition variables.
2. Project Overview
Your project will be composed of two types of threads: dispatcher thread and worker threads.The
purpose of the dispatcher threads is to repeatedly accept an incoming connection, read the client request
from the connection, and place the request in a queue. We will assume that there will only be one request
per incoming connection. The purpose of the worker threads are to monitor the request queue, retrieve
requests (in the form of an input image) and read the image into memory (ie. get the bytes of the image),
match the image against a database of images, and serve the best or closest matching image back to the
user. The queue is a bounded buffer and will need to be properly synchronized. All client-server
communication is implemented for you.
3. Server Overview
Your server should create a fixed pool of worker and dispatcher threads when the program starts.
The worker thread pool size should be num_worker (you can assume that the number of worker threads
will be less than the number of requests) and dispatcher thread should be of size num_dispatcher. Your
server should bring the database of images into memory when the server starts up.
3.1 Server Database:
● The database is a directory filled with images. These images are utilized for comparing
input images received from clients, with the closest match subsequently returned to the
respective client. It is imperative to load this database into memory upon the server's
startup to ensure efficient access during the matching process.
3.2 Request Queue Structure:
● Request Queue Structure: Each request inside the queue will contain an image (i.e. a stream of
bytes) sent from the client via an image file they specify and file descriptor of where to send the
best matching image back. You may use a struct to hold this data before adding it to the queue.
The queue structure is up to you. You can implement it as a queue of structs or a linked list of
structs, or any other data structure you find suitable.
3.3 Dispatcher Thread
The purpose of the dispatcher threads is to repeatedly accept an incoming connection, read the
client request from the connection (i.e. the image contents), and place the request in a queue. We will
assume that there will only be one request per incoming connection. You will use locks and condition
variables (discussed Thursday) to synchronize this queue (also known as a bounded buffer). The queue is
of fixed size.
● Queue Management: The identified image stream of bytes are added to the request queue along
with a file descriptor of where to send the image back. This queue is shared with the workers.
● Signaling New Request: Once a request is added to the request queue, the dispatcher thread will
signal to all of the worker threads that there is a request in the queue.
● Full Queue: Once the queue is full, the dispatcher thread will wait for a signal from any worker
thread that there is a space in the queue.
● Network Functions the dispatcher will call:
○ int socketfd = accept_connection(): returns a file descriptor which
should be stored in the queue
○ Char * buffer = get_request(int socketfd, size_t *size):
Takes the file descriptor as the first argument, and takes a size_t pointer as a second
argument which will be set by this function. Returns a char * with the raw image bytes.
3.6 Worker Threads
The worker threads are responsible for monitoring the request queue, retrieving requests,
comparing images from the database with the request image, and serving the best image back to the user.
Here's a breakdown of its functionality:
● Parameters: The worker thread will take a threadID as a parameter (0, 1, 2, …) which will later
be used for logging. You can assign the threads an ID in the order the threads are created. Note
that this thread ID is different from the pthread_id assigned to the thread by the pthread_create()
function.
● Queue Monitoring: Worker threads continuously monitor the shared request queue. When a new
request arrives from the dispatcher thread, one of the worker threads retrieves it for further
processing.
● Request Handling: Once a request is obtained, a worker thread will compare against the
in-memory copy of the database for the best matching image.
● Response to request: After finding the image, the worker thread prepares the image to be served
back to the user by sending the image bytes. The client then writes the returned image into a file.
An example would be: input file is foobar.png output file could be foobar_similar.png.
● Empty Queue: Once the queue is empty, the worker thread will wait for a signal from any
dispatcher thread that there are now requests in the queue.
● Synchronization: Proper synchronization mechanisms such as mutex locks and condition
variables are used to ensure that multiple worker threads can safely access and modify shared
data structures (queues) and other global variables without race conditions or deadlocks.
● Network Function the worker will make:
○ database_entry_t image_match(char *input_image, int size):
○ send_file_to_client(int socketFd, char *buffer, int size):
Takes the client file descriptor, the matching image memory block, and its size.
3.8 Request Logging
The worker threads must carefully log each request to a file called “server_log” and also to the
terminal (stdout) in the format below. The log file should be created in the same directory where the final
executable “server” exists. You must also protect the log file from race conditions. The format is:
[threadId][reqNum][fd][Request string][bytes/error]
● threadId is an integer from 0 to num_workers -1 indicating the thread index of request
handling worker. (Note: this is not the pthread_t returned by pthread_create).
● reqNum is the total number of requests a specific worker thread has handled so far, including
the current request (i.e. it is a way to tag each request uniquely).
● fd is the file descriptor given to you by accept_connection() for this request
● database string is the image filename sent by the server
● bytes/error is either the number of bytes returned by a successful request.
The log (in the “server_log” file and in the terminal) should look something like the example below. We
provide the code for this.
[8][1][5][/DB/30.jpg][17772]
[9][1][5][/DB/30.jpg][17772]
Make sure serer_log file is opened for write with truncation to 0.
3.8 Server termination
We will keep this very simple: ^C. If you wish you can catch ^C, and do some cleanup or
goodbye, but not needed. If the client is running, then this may hang the client or possibly make it crash.
Do not worry about that.
4. Client Overview
Your client will take a directory name as command line argument and be tasked with traversing
its contents. For each file encountered within the directory, the client will initiate a thread to request the
server to process it. This thread will handle the transmission of the file to the server for processing.
Subsequently, the thread will remain active, awaiting the receipt of the corresponding matching image
from the server, writing the contents to a file, and then terminating. The reason the client is multithreaded
is to emulate multiple concurrent requests to the server.
4.1 Client Main Thread
● Directory Traversal: The main thread will traverse the directory contents, for each image
encountered within the directory, it will spawn a thread to process it. This will give us some
concurrency at the server, hopefully.
4.2 Client Threads
● File Preparation: Once the thread starts it will load the image into memory and send it to the
server using send_file_to_server() function.
● User Response: After the thread successfully sends an image to the server. The thread will
remain active, awaiting the receipt of the corresponding matching image from the server.
● Matching image Handling: Once the matching image has been received by the client, the thread
will save the image into a new file and log the request.
● Network Functions the client needs to call:
○ int socketFd = setup_connection(): returns a file descriptor for where to
send data to the server
○ send_file_to_server(int socketFd FILE *fd, size_t size) :
takes a server file descriptor, the image file descriptor and size of the image.
○ receive_file(int socketFd, char * path): server file descriptor and
path to output the new image.
5. Compilation Instructions
You can create all of the necessary executable files with
Command Line
$ make
Running the program with various directories can be accomplished with
Command Line
$ ./server <Port> <Database path> <num_dispatcher> <num_workers> <queue_lenght>
$ ./client <directory path> <server Port> <output directory path>
Example:
Command Line
$ ./server 8000 database 50 50 20
$ ./client img 8000 output/img
6. Project Folder Structure
Please strictly conform to the folder structure that is provided to you. Your conformance will be graded.
Project structure Contents (initial/required contents
[1]
)
include/ .h header files (server.h client.h utils.h)
lib/ .o library files (utils.o)
src/ .c source files (server.c client.c)
database/ Contain the server database
expected/ expected output
Makefile file containing build information and used for
testing/compiling
README.md
1 This content is required at minimum, but adding additional content is OK as long as it doesn’t break the
existing code.
7. Assumptions / Notes
1. The maximum number of dispatcher threads will be 100.
2. The maximum number of worker threads will be 100.
3. The maximum length of the request queue will be 100 requests.
4. The maximum length of a filename will be 1024.
5. The maximum number of database entries is 100.
8. Documentation
Within your code you should use one or two sentences to describe each function that you write.
You do not need to comment every line of your code. However, you might want to comment portions of
your code to increase readability.
9. Submission Details
There will be two submission periods. The intermediate submission is due 1 week before the final
submission deadline. The first submission is mainly intended to make sure you are on pace to finish the
project on time. The final submission is due ~2 weeks after the project is released.
9.1 Intermediate Submission
For the intermediate submission, your task is to perform directory traversal on the server to form the
in-memory version of the database - that is, add the directory content into the database list. You will also
create N dispatcher and worker threads and join them in the main thread, with each thread printing its
thread ID and exiting. The main client thread will make one request to the server. It should just accept
the request, and print it out to stdout. There is no worker or queue needed for the intermediate. Note that
you do not need to implement any synchronization for the intermediate submission.
One student from each group should upload a .zip file to Gradescope containing all of your project files.
We’ll be primarily focusing on *.c and your README, which should contain the following information:
● Project group number
● Group member names and x500s
● The name of the CSELabs computer that you tested your code on
○ e.g. csel-kh1250-01.cselabs.umn.edu
● Any changes you made to the Makefile or existing files that would affect grading
● Plan outlining individual contributions for each member of your group
● Plan on how you are going to construct the worker threads and how you will make use of mutex
locks and condition variables.
The member of the group who uploads the .zip file to Gradescope should add the other members to
their group after submitting. Only one member in a group should upload.
9.2 Final Submission
One student from each group should upload a .zip file to Gradescope containing all of the project files.
The README should include the following details:
● Project group number
● Group member names and x500s
● The name of the CSELabs computer that you tested your code on
○ e.g. csel-kh1250-01.cselabs.umn.edu
● Members’ individual contributions
● Any changes you made to the Makefile or existing files that would affect grading
● Any assumptions that you made that weren’t outlined in section 7
● How could you enable your program to make EACH individual request parallelized? (high-level
pseudocode would be acceptable/preferred for this part)
The member of the group who uploads the .zip file to Gradescope should add the other members to
their group after submitting. Only one member in a group should upload.
Your project folder should include all of the folders that were in the original template. You can add
additional files to those folders and edit the Makefile, but make sure everything still works. Before
submitting your final project, run “make clean” to remove any existing output/ data and manually remove
any erroneous files.
10. Miscellaneous
1. We will provide an initial set of code, but you will be doing most of the coding.
2. Do not use the system call “system”.
3. Said before: KILL all of your stray processes during debugging as needed.
4. Any provided binaries are meant for the CSELAB Linux environment. No other binaries will be
distributed.
5. ChatGPT or other significant “other” code reuse is prohibited. The purpose of this course is to
learn by doing, and not meeting some deadline. If you are unsure about any located online code,
contact us.
6. On the other hand, locating code snippets that show how system calls can be used is fine
11. Rubric (tentative)
● [10%] README
● [15%] Intermediate submission
● [15%] Coding style: indentations, readability, comments where appropriate
● [20%] Test cases
● [30%] Correct use of pthread_create(), pthread_join(), pthread_mutex_t , pthread_cond_t,
pthread_mutex_lock(), pthread_mutex_unlock(), pthread_cond_wait(), pthread_cond_signal()
● [10%] Error handling — should handle system call errors and terminate gracefully
Additional notes:
● We will use the GCC version installed on the CSELabs machines to compile your code. Make
sure your code compiles and runs on CSELabs.
● A list of CSELabs machines can be found at https://cse.umn.edu/cseit/classrooms-labs
○ Try to stick with the Keller Hall computers since those are what we’ll use to test your
code
● Helpful GDB manual. From Huang: GDB Tutorial From Kauffman: Quick Guide to gdb

請加QQ:99515681  郵箱:99515681@qq.com   WX:codehelp










 

標簽:

掃一掃在手機打開當前頁
  • 上一篇:JC3509編程代做、代寫Python程序設(shè)計
  • 下一篇:代寫CSCI 2122、C++程序語言代做
  • 無相關(guān)信息
    昆明生活資訊

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

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

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

    免费一级欧美片在线观看网站_国产一区再线_欧美日本一区二区高清播放视频_国产99久久精品一区二区300
    懂色av噜噜一区二区三区av| 制服丝袜中文字幕一区| 亚洲欧美另类在线| 日本精品一区二区三区高清| 一区二区三区四区精品在线视频| 在线欧美日韩精品| 午夜欧美2019年伦理| 这里是久久伊人| 精品一区二区三区的国产在线播放| 精品国产免费人成电影在线观看四季| 国产在线视频一区二区| 欧美精彩视频一区二区三区| 白白色亚洲国产精品| 亚洲黄网站在线观看| 7777精品伊人久久久大香线蕉最新版| 蜜臀av性久久久久蜜臀aⅴ四虎| 久久一二三国产| 成人黄色免费短视频| 亚洲自拍与偷拍| 日韩一区二区电影| 国产成人午夜精品影院观看视频| 亚洲欧洲三级电影| 欧美视频中文字幕| 久久99精品一区二区三区| 国产女人18毛片水真多成人如厕| 99视频精品全部免费在线| 亚洲一区免费视频| 日韩欧美中文字幕制服| 丁香天五香天堂综合| 亚洲精品国产精品乱码不99| 91精品国产91久久综合桃花 | 综合激情成人伊人| 欧美猛男超大videosgay| 狠狠久久亚洲欧美| 亚洲免费观看高清完整| 91精品国产一区二区三区香蕉| 国产乱人伦偷精品视频免下载| 亚洲精品日韩一| 日韩午夜激情免费电影| 成人午夜电影小说| 亚洲v中文字幕| 久久天天做天天爱综合色| 91麻豆自制传媒国产之光| 日韩高清一级片| 欧美国产日韩在线观看| 欧美日韩精品一区二区在线播放| 国产精品综合一区二区| 夜夜精品视频一区二区| wwww国产精品欧美| 欧美熟乱第一页| 国产成人精品一区二区三区网站观看| 亚洲高清视频在线| 国产欧美一区视频| 91精品婷婷国产综合久久性色| 国产69精品一区二区亚洲孕妇| 亚洲大片精品永久免费| 中文乱码免费一区二区| 777久久久精品| 91免费在线看| 国内外成人在线| 性做久久久久久| 亚洲欧洲日韩女同| 精品精品国产高清一毛片一天堂| 一本久久a久久精品亚洲| 国产一区在线不卡| 日韩国产高清影视| 亚洲欧洲性图库| 久久久久国产精品人| 欧美视频在线一区| 99精品久久久久久| 国精品**一区二区三区在线蜜桃| 亚洲国产欧美在线人成| 国产精品久久毛片av大全日韩| 日韩欧美一级精品久久| 色婷婷综合久久久久中文 | 国产美女主播视频一区| 午夜精品影院在线观看| 综合精品久久久| 日本一区二区免费在线| 精品区一区二区| 欧美精品久久99久久在免费线| 91视视频在线观看入口直接观看www | 欧美亚洲国产一区二区三区| 不卡的av在线| 国产精品一级在线| 久久精品久久精品| 日韩精品高清不卡| 亚洲在线视频免费观看| 最好看的中文字幕久久| 欧美韩国日本不卡| 久久久www成人免费毛片麻豆 | 91免费视频观看| 不卡av在线免费观看| 国产福利一区二区三区视频在线 | 色综合咪咪久久| 成人av在线网站| 国产成人午夜高潮毛片| 国产在线视视频有精品| 久久se精品一区精品二区| 日本中文字幕一区二区视频 | 看电影不卡的网站| 另类小说视频一区二区| 日本中文字幕不卡| 日本怡春院一区二区| 日日夜夜一区二区| 日韩精品一级二级 | 国产清纯白嫩初高生在线观看91| 精品福利一二区| 欧美xxx久久| 欧美tickling挠脚心丨vk| 欧美不卡一区二区三区四区| 欧美一级片在线看| 日韩免费视频一区二区| 日韩欧美亚洲一区二区| 欧美一级日韩一级| 日韩欧美123| 精品久久久久久久久久久久包黑料| 欧美一区二区三区免费大片 | 亚洲欧美日韩精品久久久久| 亚洲另类色综合网站| 亚洲精品一二三| 久久er99热精品一区二区| 欧美又粗又大又爽| 欧美午夜在线一二页| 欧美性色黄大片手机版| 欧美日韩精品久久久| 91麻豆精品国产91久久久| 欧美一区二区三区日韩视频| 欧美一级高清片| 精品裸体舞一区二区三区| 久久婷婷色综合| 欧美国产精品一区| 国产精品久久久久久久久动漫| 国产精品家庭影院| 亚洲精品久久7777| 香蕉影视欧美成人| 麻豆精品国产91久久久久久| 韩日精品视频一区| 成人国产电影网| 在线视频一区二区免费| 欧美精品日日鲁夜夜添| 精品国产成人系列| 中文av一区二区| 尤物av一区二区| 日韩国产高清影视| 国产裸体歌舞团一区二区| 波多野结衣亚洲| 欧美日韩一区小说| 日韩免费高清av| 国产精品午夜在线观看| 一区二区三区在线免费播放 | 国产成人精品影视| 色一情一乱一乱一91av| 91精品国产一区二区三区| 26uuu精品一区二区| 亚洲日本韩国一区| 日本在线不卡一区| 国产91丝袜在线播放| 欧亚洲嫩模精品一区三区| 日韩欧美亚洲国产精品字幕久久久| 国产日产精品一区| 亚洲免费av在线| 麻豆成人免费电影| 91最新地址在线播放| 欧美一区二区视频网站| 国产欧美日韩激情| 亚洲国产日韩在线一区模特| 裸体健美xxxx欧美裸体表演| 成人黄色片在线观看| 欧美男人的天堂一二区| 国产欧美一区二区精品仙草咪| 一区二区三区电影在线播| 久久成人精品无人区| 色综合天天天天做夜夜夜夜做| 91精品国产综合久久久久| 中文字幕不卡在线观看| 午夜精品久久久久影视| 成人夜色视频网站在线观看| 欧美日韩国产电影| 欧美高清在线视频| 日韩成人dvd| 91老司机福利 在线| 欧美va亚洲va在线观看蝴蝶网| 亚洲视频在线一区观看| 狠狠网亚洲精品| 欧美羞羞免费网站| 国产欧美精品一区二区三区四区 | 五月婷婷久久丁香| 成人久久久精品乱码一区二区三区 | 久久综合九色综合97_久久久| 亚洲精品亚洲人成人网| 国模娜娜一区二区三区| 欧美日韩一级视频| 国产精品理伦片| 国内国产精品久久| 成人精品gif动图一区| 91精品国产aⅴ一区二区| 亚洲欧洲精品一区二区精品久久久| 美女网站在线免费欧美精品| 在线观看一区二区视频|