对裸机使用 pthread 的交叉编译程序 [英] Cross compile program which uses pthreads for bare metal

查看:48
本文介绍了对裸机使用 pthread 的交叉编译程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这可能是一个非常笼统的问题,但我不熟悉这个话题,很高兴得到任何提示.

OK, this might be a very general question but I'm not to familiar with the topic and happy for any hint.

我有一个来自 SoucereyCodeBench for ARM 的交叉编译工具链 (arm-xilinx-linux-gnueabi-).我交叉编译了一个使用编译器选项的库:-DSC_INCLUDE_FX -DSC_USE_PTHREADS -pthreads -fPIC -DPIC

I have a Cross Compiling tool chain from SoucereyCodeBench for ARM ( arm-xilinx-linux-gnueabi-). I cross compiled a library which uses the compiler Options: -DSC_INCLUDE_FX -DSC_USE_PTHREADS -pthreads -fPIC -DPIC

所以如果我想将库用于裸机程序,我猜我需要裸机编译器的 pthreads (arm-xilinx-eabi-)?

So if I want to use the libary for bare metal program I would need pthreads for the bare metal compiler (arm-xilinx-eabi-) I guess?

否则我的程序可能一开始就无法运行或编译.那么可以为裸机编译pthreads吗?

Otherwise my program probally wouldn't run or compile in the first place. So could it be done to compile pthreads for bare metal?

推荐答案

我认为这将是移植您的代码而不是简单地交叉编译代码的一个重要问题.顾名思义,POSIX 线程(pthreads)采用 POSIX API.

I think it will be a matetr of porting your code rather than simply cross-compiling it unchanged. As its name suggests POSIX threads (pthreads) assumes a POSIX API.

如果您需要裸机 ARM 目标上的线程,那么您至少需要某种线程调度库,其中有 很多.大多数 RTOS 不是 Linux 意义上的完整操作系统,而是具有 IPC 机制的简单调度程序,这些调度程序像任何其他静态库一样链接到您的单体应用程序 - 从系统直接引导到您的 main() 函数,您负责创建任务/线程并启动调度程序.

If you need threads on a bare metal ARM target, the you at least need some sort of thread scheduling libraries of which there are many. Most RTOSs are not full OSs in the sense of Linux, but rather simple schedulers with IPC mechanisms that link as static libraries like any other to your monolithic application - that probably still counts as "bare metal" in the sense that the system boots directly to your main() function where you are responsible for creating tasks/threads and starting the scheduler.

一些 RTOS 支持 POSIX API,因此支持 pthread,但这些往往是更大更完整的操作系统,而不是简单的调度程序 - 无论哪种方式,它们通常比 Linux 更小且可扩展性更强,因此仍然可以满足您的裸机"要求.

Some RTOSs support POSIX APIs and therefore pthreads, but these tend to be the larger more complete OSs rather than simple schedulers - either way they are generally smaller and more scalable then Linux so may meet yout "bare metal" requirements nonetheless.

当然,没有什么能阻止您围绕任何 RTOS 库创建包装器以提供 pthread 兼容的 API,这可能会使您的代码移植更简单.

Of course nothing stops you from creating a wrapper around any RTOS library to provide a pthread compatible API that might make porting your code simpler.

这篇关于对裸机使用 pthread 的交叉编译程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆