All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [BUILDROOT] CPU allocation for a thread with CPU_SET, CPU_ZERO
       [not found] <1953704638.2126656.1487343023965.ref@mail.yahoo.com>
@ 2017-02-17 14:50 ` thierry.xenomai43 at yahoo.com
  2017-02-17 20:48   ` [Buildroot] " Arnout Vandecappelle
  0 siblings, 1 reply; 2+ messages in thread
From: thierry.xenomai43 at yahoo.com @ 2017-02-17 14:50 UTC (permalink / raw)
  To: buildroot

 Hello,I would like allocate threads at one specific core with CPU_SET and CPU_ZERO.My target is a RaspberryPi 3 and I use Buildroot 2016.11.2RT + uclib 1.0.19 + PREEMPT_RT patch.
But when I compile my program I get this error :-----------------------------------------------------------------------test.c:107:1: attention : implicit declaration of function CPU_ZERO [-Wimplicit-function-declaration]
?CPU_ZERO(&thecpus);
?^
test.c:108:1: attention : implicit declaration of function CPU_SET [-Wimplicit-function-declaration]
?CPU_SET(0, &thecpus);
?^
test.c:109:5: attention : implicit declaration of function ?sched_setaffinity [-Wimplicit-function-declaration]
?if (sched_setaffinity(getpid(), sizeof(cpu_set_t), &thecpus)< 0)
-----------------------------------------------------------------------
>>> My ?<Buildroot>/output/build/uclib-1.0.19/include/sched.h? file is the next :-----------------------------------------------------------------------
[...]#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
/* Access macros for `cpu_set'.? */
# define CPU_SETSIZE __CPU_SETSIZE
# define CPU_SET(cpu, cpusetp)? __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
# define CPU_CLR(cpu, cpusetp)? __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
??????cpusetp)
[...]# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
# define CPU_ALLOC(count) __CPU_ALLOC (count)
# define CPU_FREE(cpuset) __CPU_FREE (cpuset)
/* Set the CPU affinity for a task */
extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
???????? const cpu_set_t *__cpuset) __THROW;/* Get the CPU affinity for a task */
extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
???????? cpu_set_t *__cpuset) __THROW;[...]
-----------------------------------------------------------------------
>>> My source code is the next:-----------------------------------------------------------------------
#ifndef __USE_GNU
#define __USE_GNU
#endif#ifndef __UCLIBC_LINUX_SPECIFIC__
#define __UCLIBC_LINUX_SPECIFIC__
#endif/*
#include "/home/thierry/MesProgrammes/C/buildroot/buildroot-2016.11.2RT_PREEMPT/output/build/uclibc-1.0.19/include/sched.h"
*/#include <sched.h>
#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>[...]int main ()
{
pthread_t tid1, tid2, tid3;
cpu_set_t thecpus;CPU_ZERO(&thecpus);
CPU_SET(0, &thecpus);
if (sched_setaffinity(getpid(), sizeof(cpu_set_t), &thecpus)< 0)
?? perror("set affinity");[...]
}
-----------------------------------------------------------------------
When I put a volontary syntax error on ?<Buildroot>/output/build/uclib-1.0.19/include/sched.h? I never get error when I make.
I think that the compilator don't watch a good 'sched.h' file
Do you think that is a bad path configuration?
Regard,
Thierry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170217/cee3b8c2/attachment.html>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Buildroot] CPU allocation for a thread with CPU_SET, CPU_ZERO
  2017-02-17 14:50 ` [Buildroot] [BUILDROOT] CPU allocation for a thread with CPU_SET, CPU_ZERO thierry.xenomai43 at yahoo.com
@ 2017-02-17 20:48   ` Arnout Vandecappelle
  0 siblings, 0 replies; 2+ messages in thread
From: Arnout Vandecappelle @ 2017-02-17 20:48 UTC (permalink / raw)
  To: buildroot



On 17-02-17 15:50, thierry.xenomai43 at yahoo.com wrote:
> My target is a RaspberryPi 3 and I use Buildroot 2016.11.2RT + uclib 1.0.19 + PREEMPT_RT patch.

 I assume you do have threads enabled?

[snip]
>>>> My source code is the next:
> -----------------------------------------------------------------------
> #ifndef __USE_GNU
> #define __USE_GNU
> #endif
> #ifndef __UCLIBC_LINUX_SPECIFIC__
> #define __UCLIBC_LINUX_SPECIFIC__
> #endif

 As explained in the man page, you should define _GNU_SOURCE instead of these.

> /*
> #include
> "/home/thierry/MesProgrammes/C/buildroot/buildroot-2016.11.2RT_PREEMPT/output/build/uclibc-1.0.19/include/sched.h"

 What gets used is .../output/staging/usr/include/sched.h, but that should just
be a copy of this file.

> */
> #include <sched.h>

 This *should* actually be sufficient. You don't pass something like
-I/usr/include, do you?

 You can compile with -E instead of -c to see what exactly gets #included and
where the symbols get defined (or not).


 Regards,
 Arnout

> #include <stdio.h>
> #include <pthread.h>
> #include <semaphore.h>
> #include <time.h>
> #include <stdlib.h>
> #include <unistd.h>
> [...]
> int main ()
> {
> pthread_t tid1, tid2, tid3;
> cpu_set_t thecpus;
> CPU_ZERO(&thecpus);
> CPU_SET(0, &thecpus);
> if (sched_setaffinity(getpid(), sizeof(cpu_set_t), &thecpus)< 0)
>    perror("set affinity");
> [...]
> }
> -----------------------------------------------------------------------
> 
> When I put a volontary syntax error on
> ?<Buildroot>/output/build/uclib-1.0.19/include/sched.h? I never get error when I
> make.
> I think that the compilator don't watch a good 'sched.h' file
> Do you think that is a bad path configuration?
> 
> Regard,
> Thierry
> 
> 
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-17 20:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1953704638.2126656.1487343023965.ref@mail.yahoo.com>
2017-02-17 14:50 ` [Buildroot] [BUILDROOT] CPU allocation for a thread with CPU_SET, CPU_ZERO thierry.xenomai43 at yahoo.com
2017-02-17 20:48   ` [Buildroot] " Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.