- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 UPC 中编程,并且有一个在两个线程之间共享的数组。每个线程都有指向这些共享区域的私有(private)指针:
#define SIZE 10000
#define HALFSIZE (SIZE/2)
shared [ HALFSIZE ] int table [ SIZE ]; /* all areas */
shared [ HALFSIZE ] int *first_area_pt; /* points to first thread area */
shared [ HALFSIZE ] int *second_area_pt; /* points to second thread area */
现在我想要的不是 2 个,而是 N 个线程、N 个区域和 N 个指针。所以我需要这些指针的数组:
shared [ HALFSIZE ] int *first_area_pt;
shared [ HALFSIZE ] int *second_area_pt;
我应该如何定义它?
最佳答案
假设您使用的是静态线程编译环境,声明数组的更简洁的方法是这样的:
#define SIZE 10000
shared [*] int table [ SIZE ]; /* data automatically blocked across THREADS */
shared [1] int *base = (shared [1] int *)&table;
然后您可以使用循环基指针创建一个指向共享的指针,引用与线程 X 具有亲和性的数据,表达式如下:
shared [] int *threadXdata = (shared [] int *)(base+X);
使用这种方法,您永远不需要为 THREADS 指针数组实例化存储。然而,如果你真的想要,你当然可以用这样的东西声明和初始化一个:
shared [] int *threadptr[THREADS];
for (int i=0; i < THREADS; i++) threadptr[i] = (shared [] int *)(base+i);
...
threadptr[4][10] = 42; /* example access to element 10 on thread 4*/
这里的 threadptr 是一个本地指针数组,用作每个线程数据的引用目录。
请注意,以上所有内容都使用无限阻塞的共享指针来访问与单个线程具有亲和性的元素,因为每个 block 在逻辑上都是一个连续的数据 block ,没有跨线程包装。
关于c - UPC 中指向共享数组的私有(private)指针数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8695847/
我们想将 12 位 UPC-A 转换为 8 位 UPC-E。您能告诉我哪种方法最好,而无需使用我自己的代码进行转换吗? 我有很多公式可以将 8 位 UCC-E 转换为 12 位 UPC-A 但不能反转
将零抑制的八位 GTIN-12 标识符(表示为 UPC-E 条形码)转换为 UPC-A 条形码中显示的完整十二位版本的算法是什么? 最佳答案 从以下模式映射可以最清楚地看出在 UPC-E 和 UPC-
我正在尝试将 UPC-E 转换为 UPC-A,但我看到了奇怪的结果。我相信它们可能是正确的,因为我发现的两个引用站点显示了相同的转换,但我认为 UPC-E 应该明显地转换为 UPC-A。 678905
有没有什么格式我们可以用来识别 UPC 代码而不是只检查位数? 最佳答案 我有一些 Objective-C 代码可以验证用户输入的字符串,看它是否是有效的 UPC 或 EAN 条形码。这支持 UPC、
我想在全局地址空间中声明一个共享矩阵,但不通过 UPC 线程执行任何计算,而是使用 CUDA 的 GPU。 那么是否可以声明一个 UPC 共享数组,其中数组中的数字元素不等于或不是线程数(THREAD
我一直在试图找出为什么我的输出不是它应该的样子。给出的示例是 Enter a UPC (enter a blank line to quit): 036000291453 Check digit sh
我有一个包含 12 位 UPC-A 格式条码(1,900,000 条记录)的 UPC 数据库。由于前导零,目前它们存储为 varchar(13)。我正在使用 SQL Server 2008 R2。 我
我已查看文档,但尚未了解如何根据 UPC 进行搜索。 我可以看到我从每张专辑中得到了什么,但如何进行查找? 有人知道吗? 最佳答案 这是 UPC 专辑查找的格式:http://api.deezer.c
我一直在尝试使用Zxing 2.3.0在java中读取带有+5补充的UPC条形码图像,但是我无法读取条形码的补充部分。该代码仅成功读取第一部分。在搜索了多个网站之后,除了我当前的方法之外,我找不到任何
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我的工作环境是Visual Studio 2008 + C# 我在 Amazon WebService 上工作,我想使用 SOAP 从 Amazon 获取数据,但是当我尝试传递 IDType = UP
我正在使用 zxing 在我的应用程序中实现条码扫描器。问题是扫描结果始终将 UPC-E 检测为扫描格式并返回错误结果。有什么办法可以解决这个问题吗? 我正在使用以下代码启动扫描: Intent i
我正在跟踪一家链式店的杂货价格,但我在使用 MySQL 语句时遇到了问题。 我的三个表的设置如下: upccode_table,有两个字段:upc_code、item_name storelist_t
我们使用 Zxing API 将字符串生成为 upc-a 条码图像。但是该图像仅包含条形码,但不包含如下链接图像中的字符串: https://postimg.org/image/7t66lqa83/
我需要一些关于如何从 bmp 文件中获取 12 位条形码的指导,我完全不知道如何处理这个问题。我首先将图像读入 bitmam,我该如何继续? 例子:下图的条码是081034489030。我如何获得这些
我正在尝试在具有 CPU/GPU 混合节点的集群上使用 UPC。环境是Ubuntu 12.04。我是 UPC 的新手,我发现了 2 个版本的 UPC:GNU UPC(GUPC) 和 Berkeley
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 11 年前。 Improve thi
虽然我已经阅读了很长时间有关 PHP 的内容以及我遇到的一些 Android 问题,但我是堆栈溢出方面的新手。 我的问题是如何从条形码扫描仪获取数据(仅 UPC 代码和图像)以便将其插入 MySQL
很难说出这里问的是什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或言辞激烈,无法以目前的形式合理回答。如需帮助澄清此问题以便可以重新打开,visit the help center . 8年前关闭
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭10
我是一名优秀的程序员,十分优秀!