名称: 并发原语 描述: 实现语言级并发支持的专家技能,包括线程、通道和同步 类别: 运行时 允许的工具:
- 读取
- 写入
- 编辑
- 全局匹配
- 文本搜索
- Bash
并发原语技能
概述
实现语言级并发支持的专家技能,包括线程、通道和同步。
能力
- 设计线程API和原语
- 实现互斥锁和条件变量
- 实现基于通道的消息传递
- 设计异步/等待和协程系统
- 实现工作窃取调度器
- 处理线程本地存储
- 设计内存模型和排序
- 实现绿色线程/goroutine
目标流程
- concurrency-primitives.js
- interpreter-implementation.js
- bytecode-vm-implementation.js
- garbage-collector-implementation.js
依赖
并发理论,Go调度器参考资料
使用指南
- 模型选择: 根据语言目标在共享内存和消息传递之间选择
- 内存模型: 明确定义内存排序语义
- 调度: 设计调度器时考虑公平性和效率
- 集成: 确保垃圾回收和并发正确协同工作
- 测试: 从一开始就构建并发压力测试
输出模式
{
"type": "object",
"properties": {
"model": {
"type": "string",
"enum": ["shared-memory", "message-passing", "actor", "csp"]
},
"primitives": {
"type": "array",
"items": { "type": "string" }
},
"schedulerType": {
"type": "string",
"enum": ["os-threads", "green-threads", "work-stealing", "cooperative"]
},
"generatedFiles": {
"type": "array",
"items": { "type": "string" }
}
}
}