CSIL machines for multi-threaded programming

SpringBoot+Vue+MySQL 高校学科竞赛平台 完整可运行版(源码+文档) 本项目基于SpringBoot+Vue+MySQL构建高校学科竞赛管理平台,覆盖学生、教师、领队教师、管理员四大角色,实现竞赛发布、报名、刷题、评分、公示等全流程闭环管理。系统架构清晰,技术主流,配套完整源码、数据库脚本、万字论文、开题报告、答辩PPT及部署文档,支持一键运行,适用于毕业设计、课程设计及院系二次开发,真正实现“开箱即用”。 阅读详情


Assignment 1
Due Thursday by 11:59pm Points 60 Submitting a file upload
Available Sep 2 at 3pm - Dec 24 at 11:59pm
Start Assignment
Assignment 1 [60 Points]
Due: Friday September 12 at 11:59 PM
This assignment is a refresher for multi-threaded programming using pthreads. You have one problem in
this assignment and you are provided the source code (with a driver program for executing the solution),
the test script, and the expected output to be generated by your solution. You are expected to fill the
various functions (explained in detail below) in order to complete the assignment. You can find a tutorial
for pthreads at: https://computing.llnl.gov/tutorials/pthreads/
(https://computing.llnl.gov/tutorials/pthreads/) for a quick review.
You need to test and debug your program on CSIL machines. You can find instructions on how to run
remotely on CSIL machines at: https://www.sfu.ca/computing/about/support/csil/remote?access.html (https://www.sfu.ca/computing/about/support/csil/remote-access.html)
For a list of available CSIL machines to use:
https://www.sfu.ca/computing/about/support/csil/unix/how-to-use-csil-linux-cpu-server.html
(https://www.sfu.ca/computing/about/support/csil/unix/how-to-use-csil-linux-cpu-server.html)
Note: For future assignments, you may need to run on a private cluster that we'll provide information
about soon.
General Instructions
1. You are provided with source code to start with here: assignment1.tar.gz
(https://canvas.sfu.ca/courses/84236/files/24448327?wrap=1)
(https://canvas.sfu.ca/courses/84236/files/24448327/download?download_frd=1) . The compiler used is
`g++ 9.4.0` and is already installed on CSIL machines. To run the program, follow the steps below:
a. Run
 make producer_consumer
This creates a binary file called `producer_consumer`.
 b. Test the binary:
 Assignment 1
1/6
 ./producer_consumer --nItems 1000000 --nProducers 4 --nConsumers 2 --bufferSize 50000

 Note that `--nProducers` and `--nConsumers` are used to specify the number of producer and
consumer threads. So, the above command will create 6 threads. (Detailed description about the various
arguments for `producer_consumer` can be found below.)
2. You will be asked to print the time spent by different threads on specific code regions. The time spent
by any code region can be computed as follows:
timer t1;
? ? t1.start();
? ? /* ---- Code region whose time is to be measured --- */
 double time_taken = t1.stop();
3. Sample outputs for all the programs can be found in `sample_outputs` directory. Programs will be
evaluated and graded automatically. Please make sure that your program output strictly follows
the sample output format.
4. We have provided test scripts for you to quickly test your solutions during your development process.
You can test your code using the test script, `test_scripts/solution_tester.py`. Note that these test scripts
only validate the output formats, and a different evaluation script will be used for grading the
assignments.
Producer-Consumer Problem
In this problem, we want to create `p` producer threads that produce `n` items in total, and `q` consumer
threads consuming those items. Each producer thread produces n/p items (integer division). Any
remaining items will be produces by producer thread 0. For example, if n=1000 and p = 3, producers 1
and 2 will produce 333 items while producer 0 will produce 334 items. Each item has a unique value that
is determined by the producing thread ID and the total number of producers. In the previous example,
thread 0 will generate item values 0, 3, 6, 9,...; thread 1 will generate item values 1, 4, 7, 10,...; and
thread 2 will generate item values 2, 5, 8, 11,...
The produced items belong to one of three types (type 0, type 1 and type 2). Type 0 represents half the
items produced by each producer, Type 1 represents a third, and Type 2 represents the rest. For
example, if a thread needs to produce "items_to_produce" then it needs to produce
"items_to_produce/2" type 0 items, "items_to_produce/3" type 1 items, and the remaining from
items_to_produce are type 2 items.
The produced items are enqueued in a buffer queue called `production_buffer` (the implementation for
the queue is available in `core/circular_queue.h`), and are dequeued for consumption. Each element in
the queue has an item value, an item type, and its producer thread ID. Both producer and consumer
threads operate concurrently. Since multiple producer threads enqueue the items and multiple consumer
 Assignment 1
2/6
threads dequeue the items from the *same queue*, you should use mutex when accessing the queue
(critical section).
In addition, care must be taken to carefully handle when the `production_buffer` is full or empty to avoid
overflow (items cannot be produced when queue is full) and underflow (items cannot be consumed when
queue is empty). Each producer should correctly produce its items (total n for all producers) and the total
number of items consumed by all the consumers should be equal to the total number of items produced.
You are expected to use conditional variables as required to ensure correctness and to prevent any
deadlocks or infinite waiting.
In order to evaluate correctness, we also compute the *value* of items produced/consumed by each
thread. For producers, the *value produced* is the sum of all the items produced (and enqueued) and for
consumers, the *value consumed* is the sum of all the items consumed. Each consumer also needs to
keep track of the total value it consumed from each type. The total value of items produced for a certain
type should equal the total number of items consumed from that type by all consumer threads.
The logic for both the producer and consumer threads is shown below. Make sure your solution retains
the *long* datatype for variables, as shown below:
**Producer threads:**

 // also update item count and value for item type produced
else {
 // production_buffer is full, so block on conditional variable waiting for consumer
to signal.}
// After production is completed:
// Update the number of producers that are currently active.
 --active_producer_count;
// The producer that was last active (can be determined using `active_producer_count`) will
keep signalling the consumers until all consumers have finished (can be determined using `active_con
sumer_count`). }
**Consumer threads:**
 consumerFunction(){
// Each consumer dequeues items from the `production_buffer`?
 long item;
 Assignment 1
3/6
 long items_consumed = 0;
long value_consumed = 0; 
while(true) {
bool ret = production_buffer.dequeue(&item); // item includes value and type
if(ret == true) {
 if(production_buffer.itemCount() == production_buffer.getCapacity() - 1){
// The queue is no longer full
 // Signal all producers indicating queue is not full }
 value_consumed += item;
 items_consumed++;
 // also update value and count for consumed item type }
 else {
// production_buffer is empty, so block on conditional variable waiting for producer
to signal.
 // The thread can wake up because of 2 scenarios:
// Scenario 1: There are no more active producers (i.e., production is complete) and
the queue is empty. This is the exit condition for consumers, and at this point consumers should dec
rement `active_consumer_count`.
// Scenario 2: The queue is not empty and/or the producers are active. Continue cons
uming.

In addition, you are provided the following methods for the `ProducerConsumerProblem` class in
`solution.cpp` file. 
1. `ProducerConsumerProblem()` and `~ProducerConsumerProblem()` - Constructor and destructor for
the `ProducerConsumerProblem` class. You can initialize/destroy your mutexes and conditional variables
here.
2. `startProducers()` and `startConsumers()` - Methods where producer and consumer threads should be
created respectively (use `pthread_create()` here).
3. `joinProducers()` and `joinConsumers()` - Methods where producer and consumer threads should be
joined with the main thread.
4. `printStats()` - Method to print statistics of the producer and consumer threads (see output
requirements below).
**NOTE: You should not change the signature (i.e., function names, parameters, return types) of
these 7 methods. To evaluate your solutions, we will use different driver programs that will rely
on the provided function signatures. You can define additional structs, classes or functions in
solution.cpp or solution.h as necessary.**
The driver program (in `driver.cpp`) processes the following command-line parameters, and calls various
methods of the `ProducerConsumerProblem` class.
1. `--nItems`: the total number of items produced all producers.
2. `--nProducers`: the number of producer threads.
3. `--nConsumers`: the number of consumer threads.
4. `--bufferSize`: the size of the buffer used for `production_buffer`.
 Assignment 1
4/6
Your solution must satisfy the following:
1. The executable should support the 4 command-line parameters mentioned above. This is already
taken care by `driver.cpp` and make sure your solution is not dependent on any other command-line
parameters since the driver program used for evaluation may not be the same.
2. Output the following (sample output can be found in `sample_outputs/producer_consumer.output` file):
 1. The total number of producer and consumer threads.
 2. For each producer thread: the producer id, the number of items produced by the producer for type
0, the total value of the items produced for type 0, the number of items produced by the producer for
type 1, the total value of the items produced for type 1, the number of items produced by the producer
for type 2, the total value of the items produced for type 2, total value produced for all types, the time
taken by the producer thread (i.e. time between the start and end of the producer function).
 3. For each consumer thread: the consumer id, the number of items consumed by the consumer for
type 0, the total value of the items consumed for type 0, the number of items consumed by the consumer
for type 1, the total value of the items consumed for type 1, the number of items consumed by the
consumer for type 2, the total value of the items consumed for type 2, the time taken by the consumer
thread (i.e. time between the start and end of the consumer function), and the total value consumed from
each producer thread (thread 0, thread 1 etc.).
 4. The total number of items consumed by all consumers.
 5. The total time taken (this is already printed by the driver program).
Please note that the output format should strictly match the expected format (including "spaces" and
"commas"). You can test your code using the test script as follows:
 $ python test_scripts/solution_tester.pyc --execPath=<absolute path of producer_consumer executa
ble file> --scriptPath=./test_scripts/solution_evaluator.pyc
Submission Guidelines
Make sure that your solutions folder has the following files and sub-folders. Let's say your solutions
folder is called `my_assignment1_solutions`. It should contain:
 `core/` -- The folder containing all core files. It is already available in the assignment package. Do not
modify it or remove any files.
 `Makefile` -- Makefile for the project. This file should not be changed.
 `driver.cpp`-- Main program for the assignment. This file should not be changed.
 `solution.cpp`-- You should modify this file
 `solution.h`-- You should modify this file
To create the submission file, follow the steps below:
 1. In your solutions folder, remove all the object/temporary files.
 Assignment 1
5/6
  $ cd my_assignment1_solutions/
$ make clean 
 $rm *.gz
 2. Create the tar.gz file. 
 $ tar cvzf assignment1.tar.gz *
 which creates a compressed tar ball that contains the contents of the folder.
 3. Validate the tar ball using the `submission_validator.py` script.
 $ python test_scripts/submission_validator.pyc --tarPath=<full path to tarball>/assignment1. 4. Submit the tar.gz file via canvas before the deadline.

无人机巡检提速3倍!YOLOv8n+OpenVINO让Jetson Nano跑25FPS,还能多飞25分钟 摘要(149字): 针对无人机巡检中Jetson Nano算力不足导致的帧率低、首次推理延迟高、续航短等问题,提出YOLOv8n+OpenVINO联合优化方案: 模型轻量化:YOLOv8n参数量仅3.2M(较v8s减少71%),Jetson Nano帧率从8FPS提升至15FPS(原生),绝缘子裂纹召回率仅降3%; OpenVINO加速:AUTO模式动态分配CPU/GPU算力,首次推理延迟从500ms降至200ms,帧率再优化至25FPS; 能效提升:功耗降低40%,单次续航延长25分钟。方案已落地电力/林 阅读详情

相关推荐

ElementUI时间选择器(el-date-picker)输入格式的智能转换与动态适配

本文深入探讨了ElementUI时间选择器(el-date-picker)在处理用户自由格式输入时的痛点,并提出了基于Vue自定义指令的智能转换解决方案。该方案通过核心解析函数自动识别如“20231225”等连续数字输入,将其动态转换为标准时间格式,并确保与表单验证兼容,有效提升了后台管理系统的输入效率和用户体验。

weixin_29016833的博客 294

177.Agent-LangGraph-MCP的构成说明

MCP架构通过MCP主机、客户端与服务器的协同,实现工具、资源与提示词的统一管理。MCP服务器提供Tools、Resources、Prompts能力,MCP客户端则负责发现、调用与读取,使Agent可按需获取上下文。其核心在于将工具从Agent中抽离,封装为可复用的服务,提升灵活性与可维护性,推动AI应用高效协作。

计算机王的博客 315

SiamFC++笔记

SiamFC++: Towards Robust and Accurate Visual Tracking with Target Estimation Guidelines 文章根据这些思路:引入分类和目标状态估计分支(G1),无歧义的分类得分(G2),无先验知识的跟踪(G3)和评估质量得分(G4)来设计SiamFC ++。 SiamRPN ++和SiamFC ++的比较(红色部分代表得分高的区域): guide: G1 : 分类和状态估计任务的分离:分类任务将目标从干扰物和背景中分类出来,目标状态

木木JL的博客 9438

Docker Compose:搭建本地多服务开发环境

从一个 Java API、PostgreSQL 和 Redis 开始,配置服务名、端口、环境变量、健康检查、数据卷和依赖关系。理解 Compose 文件如何被解析、项目如何隔离,以及哪些数据不能依赖“重建容器”保留,能够把个人开发环境整理成团队可复用的启动入口。

m0_62221377的博客 478

不用公网IP,如何在内网高效搭建RustDesk远程控制服务器?基于Windows Server 2019的完整实践

本文详细介绍了在Windows Server 2019上部署RustDesk远程控制服务器的完整实践方案,无需公网IP即可实现内网高效远程控制。从环境准备、基础服务安装到网络与安全配置,提供了零成本的私有化部署指南,适用于企业、校园等内网环境。

weixin_28737073的博客 456

【AUTOSAR-E2E】-2.3-配置E2E:基于E2EPW配置一个RX接收的Signal Group(使用E2E Profile 1)

《共13页精讲》:此法也适用于E2E Profile 4/5/6/7/11/22 目录 1 检查CAN Matrix Arxml/DBC是否满足E2E需求 2 在DaVinci Developer中为Port添加E2E保护 3 在DaVinci Configurator settings设置 4 如何使用应用层的E2E保护 5 结尾 <--返回「Autosar_BSW高阶配置」总目录--> <--返回「Autosar_BSW高阶配置」专栏主页--> <-.

「汽车电子助手」的博客 3954

AI全栈实战 | 3.9-01 爬虫入门:requests 加 BeautifulSoup 三分钟跑通,但 90% 的人栽在这 4 个“礼貌“问题上

⚠️:本文内容仅用于。请遵守目标站点的服务条款与相关法律法规,不得对目标服务造成负担,不得采集、传播个人隐私数据。技术是中性的,边界在你手里。爬虫的入门技术(requests 发请求 + BeautifulSoup 解析)三分钟就能学会。真正区分"会用爬虫"和"会做爬虫的人"的,是这篇我们跑通"请求→解析→存储"的最小闭环,然后重点把"合规与礼貌"这根弦给你绷上。

源码获取 | 运行部署 | 定制二开修改,如果回复不及时请耐心等待,请见谅。 442

CarSim仿真快速入门(十八)-CarSim2021中的混合动力和纯电动系统

CarSim和TruckSim包括用于电动汽车(BEV)和混合电动汽车(HEV)的动力总成系统。电动和混合电动系统可与所有现有驱动系统配合使用,例如:FWD,RWD,AWD和多轴驱动系统。混合动力/电动系统模型还包括电池管理控制。CarSim或TruckSim中的默认动力总成是为闭环速度控制器提供的备用动力总成。要安装和使用完整的动力总成,请从Vehicle: Assembly库或Vehicle: Lead Unit 库链接到Powertrain数据集。在“动力总成”界面上,从下拉列表控件中选择以下三个选项

小明师兄的博客 7458

spring boot 4集成SQLLite,及其SQLLite的建库

spring boot 4集成SQLLite,及其SQLLite的建库

weixin_41463944的博客 231

【系列05】端侧AI:构建与部署高效的本地化AI模型 第4章:模型量化(Quantization)

量化的基本思想是减少模型中用于表示参数和激活值的比特数。在模型训练时,参数通常使用32位浮点数(FP32)进行存储,这提供了高精度,但也消耗大量的内存和计算资源。量化则将这些32位浮点数转换成低比特数表示,通常是8位整数(INT8)。量化的原理可以概括为:对浮点数范围进行校准,并将其映射到更小的整数范围内。例如,将一个FP32的权重(如-1.5到1.5)映射到INT8的范围(-128到127)。在推理过程中,模型将使用这些低精度的整数进行计算,从而大大减少了所需的计算量。量化带来的主要收益减少模型大小。

学习,输出==》再学习再输出 1220

【图像去噪】基于梯度为0法实现图像去噪附matlab代码

近几年,徐立提出的 L0 梯度最小化模型在图像平滑领域得到了广泛的应用和发展[11]. 和以往的局部滤波模型不同的是该模型可以全局的估计图像的像素值,因此,L0 梯度最小化模型在处理图像的同时能够很好的保护图像的边缘.​。

qq_59747472的博客 186

【基于 WebSocket 的多用户网页五子棋】—— 数据管理模块

但行好事,莫问前程

qq_42996461的博客 260

杰理JL701N内置flash录音配置教程

本文详细介绍了内置Flash录音功能的配置方法。主要内容包括:1) 基础模式配置(开启音乐/录音模式、Flash录音宏定义);2) 录音参数设置(格式基准值、存储区域定义、容量配置);3) MP3编码特殊处理;4) 下载时的Flash格式化操作;5) 录音开关和播放接口的使用说明。配置过程涉及多个关键文件的修改,并强调存储容量的精确分配。

qq_42014563的博客 599

OpenClaw 深度调查:把 AI 助手做成你自己的控制平面

对 openclaw/openclaw 的完整技术尽调:Gateway 架构、Agent 运行时、工具与沙箱、30 个消息通道、181 个插件、安全信任边界、工程代价与采用建议。17 章 / 10 张图,全部数字标注口径,数据截至 2026-10-31。

厚积薄发 349

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

IDEA 简介:从零认识 IntelliJ IDEA

IDEA 全称,是由 JetBrains 公司开发的一款主流 Java 集成开发环境(IDE)。它集代码编辑、编译、调试、测试、版本控制、构建管理等功能于一体,被大量 Java 开发者视为日常开发的首选工具。所谓 IDE(Integrated Development Environment,集成开发环境),就是把写代码所需的各类工具整合到同一个界面中。相比只用文本编辑器加命令行编译,IDE 能显著减少重复操作,让开发者把精力集中在业务逻辑上。

ztI10的博客 185

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

TransactionInactiveError:await 之后事务已经不活跃了

TransactionInactiveError 出现于 IndexedDB 事务已结束(非 active 状态)时调用 put、get 等操作。常见于 await 后或 setTimeout 中执行请求,因任务已完成,事务已提交或进入 finished 状态。请求必须在创建事务的同一任务中挂起,否则无效。解决方法:在 onsuccess 回调内同步发起后续操作,或提前将所有请求挂入事务。避免在异步上下文中使用事务操作,确保请求在事务活跃期内完成。

qq_40822000的博客 159

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Docker部署linkding:HTTPS与数据备份

部署私人书签库,除了让页面能够打开,还需要考虑几个实际问题:重建容器后数据是否保留、登录和保存是否正常、升级前怎样备份,以及出现 502 或 CSRF 错误时从哪里检查。本文使用 Docker Compose 部署 linkding,采用默认 SQLite 数据库,通过 Caddy 提供 HTTPS,并完成账户创建、数据持久化验证和备份。如果重建后账户或书签消失,应先检查是否换了项目目录、改了挂载路径,或者启动了另一套实例,不要急着重新初始化。遇到权限问题,应根据日志确认具体目录和运行用户,再调整权限。

tedcloud123的博客 194

云计算课程小组PPT汇报任务书

36人分为6组,每组6人;形式:生活案例调研 + 理论解读;汇报时长7‑9min;PPT建议10‑14页。

Michelle8023的博客 226

企业官网源码与数据资产交接:四项权利、五组自动检查

企业官网源码交接不仅要看压缩包,还要核域名、云资源、构建脚本、数据库恢复、权限与密钥。

sweetofmine1的博客 187

软件项目交付时,源代码之外还应该交付哪些技术资料?

软件项目交付时,除可运行程序外,还应核对源代码、数据库结构、接口文档、部署运维、测试验收和账号资产。本文从实际交付环节拆解完整资料清单,并说明合同如何约定交付范围、知识产权与维护边界。

chengduyoushu的博客 308

大表 ALTER TABLE 怎么做?NineData OnlineDDL 配置与执行实践

介绍NineData OnlineDDL大表变更实践,涵盖执行策略、切表控制、拷贝批次与可视化进度追踪。

dbasenewbie的博客 295

Java 项目实战:交友项目后台系统——网关统一鉴权与 B 端管理后台

本次改造通过引入SpringCloud Gateway实现网关统一鉴权与路由,新建mf-admin管理端复用C端域服务(Dubbo调用),实现管理员登录与用户管理四件查询。核心套路:网关白名单+双体系JWT(同工具不同payload)、管理端零直连业务库、分页形态区分(MySQL自动count/Mongo手动count)、浏览器端独立聚合。踩坑12条,附自检清单与后续改造方向,可复用于多角色后台系统。

Wang的专栏 64

MySQL报Too many open files?句柄耗尽的排查与参数配置

文章讲清 max_connections 与 open_files_limit 两个额度、句柄被谁占走、分区表为什么最容易踩,给出从 error log 到 /proc/pid/limits 的定位顺序与句柄预算算法。

「一个在数据库赛道上边学边分享的学妹」——聚焦国产数据库/信创方向、分享学习笔记、踩坑经验和行业观察。 338

SQL Server 数据库双备份:简化配置,兼顾本地留存与异机归档

本文针对中小企业SQLServer数据库备份难题,提出简化配置与本地+异机双副本方案。传统原生备份依赖手动脚本,存在配置复杂、传输易中断、日志分散、静默失败等问题。推荐使用图形化工具实现备份、本地留存与异机同步一体化管理,支持断点续传、加密传输、自动清理与版本控制,降低运维负担。双副本策略提升数据安全性,本地快速恢复,异地防硬件故障。建议定期验证恢复流程,确保备份可用性。

2501_93776716的博客 313

Agent 安全实战:间接提示注入的四个攻击面与防御体系

当 Agent 从 "生成内容" 走向 "执行动作",安全边界就从内容合规变成了权限越界。本文拆解间接提示注入在网页抓取、工具返回值、MCP 连接器、长期记忆四个位置的真实攻击路径,对照 Claude、GPT、Gemini 在工具调用权限模型上的设计差异,给出可直接落地的五层防御体系。

阡陌数智,专注大模型网关与 LLM 工程落地 288

Redis 入门详解:核心特性、重要文件与全局命令实战

本文系统介绍了Redis的核心特性、重要文件及全局命令。Redis凭借内存存储、C语言实现和单线程设计,具备极高的读写性能;支持持久化(RDB/AOF)、主从复制与集群架构,适用于缓存、排行榜、计数器等场景,但不适合存储海量冷数据。文中还解析了常见面试题,如为何快速、单线程原理、持久化机制、KEYS *禁用原因及过期键处理策略,强调其在高并发场景下的优势与局限。

2303_77004089的博客 208
上一篇: ENG 5105 Project Brief Design and Construction
下一篇: ACCT20077 – ACCOUNTING FOR MANAGEMENT DECISION
wx__codinghelp
博客等级 码龄2年 514粉丝 61原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值