[Gambas-user] Gambas on Haiku?

Brian G brian at westwoodsvcs.com
Tue Feb 22 14:57:15 CET 2022


----- On Feb 22, 2022, at 2:56 AM, Benoît Minisini g4mba5 at gmail.com wrote:

> Le 22/02/2022 à 00:53, T Lee Davidson a écrit :
>> On 2/21/22 13:15, T Lee Davidson wrote:
>>> On 2/21/22 10:17, Benoît Minisini wrote:
>> [snip]
>>>> But we must add in this include file a Haiku OS function that returns
>>>> the number of physical threads the CPU(s) can handle.
>>>
>>> https://www.haiku-os.org/docs/api/:
>>> "The Haiku API is based on the BeOS R5 API but changes and additions
>>> have been included where appropriate. [... ] A complete reference to
>>> the BeOS R5 API is available on the web in The Be Book." [1]
>>>
>>> The Function Index in that book lists the get_system_info() function
>>> [2]. This function returns a system_info structure that includes
>>> fields such as cpu_count, max_threads, and used_threads.
>>>
>>> Is that what we need?
>> 
>> The following C code on Haiku (as a KVM/QEMU guest given 2 cpu's):
>> [C]
>> #include <stdio.h>
>> #include <kernel/OS.h>
>> 
>> int main() {
>> 
>>      system_info sys_info;
>> 
>>      get_system_info(&sys_info);
>>      printf("ncpus: %d\nmax_threads: %d\nused_threads: %d",
>> sys_info.cpu_count, sys_info.max_threads, sys_info.used_threads);
>>      printf("available threads: %d", sys_info.max_threads -
>> sys_info.used_threads);
>> }
>> [/C]
>> 
>> produced:
>> [console]
>> ncpus: 2
>> max_threads: 4096
>> used_threads: 150
>> available threads: 3946
>> [/console]
>> 
>> Somehow I don't think threads is what we want.
>> 
>> 
> 
> Thanks.
> 
> We actually need the number of "virtual" cpus, not the real ones.
> Normally it's the same, except with technology like "hyper-threading",
> where 1 real CPU = 2 virtual CPUs.
> 
> Can you integrate your code into the '/main/share/gb_system_temp.h' file?
> 
> Regards,
> 
> --
> Benoît Minisini
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

In testing the above code does in fact reports all real cpu and threads combined so 4 cores and 2 threads per core it reports 8 cpus


"Failure is the key to success; 
 each mistake teaches us something"  .. Morihei Ueshiba
Brian G


More information about the User mailing list