1/**
2 * \file
3 * \brief Implementation of backend functions on Linux
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#include <pthread.h>
16#include <stdio.h>
17#include <bomp_internal.h>
18
19struct bomp_state *lomp_st;
20
21#ifndef BARRELFISH
22#include <numa.h>
23
24void backend_set_numa(unsigned id)
25{
26    struct bitmask *bm = numa_allocate_cpumask();
27    numa_bitmask_setbit(bm, id);
28    numa_sched_setaffinity(0, bm);
29    numa_free_cpumask(bm);
30}
31
32void backend_run_func_on(int core_id, void* cfunc, void *arg)
33{
34    pthread_t pthread;
35    int r = pthread_create(&pthread, NULL, cfunc, arg);
36    if (r != 0) {
37        printf("pthread_create failed\n");
38    }
39}
40
41static pthread_key_t pthread_key;
42
43void *backend_get_tls(void)
44{
45    return pthread_getspecific(pthread_key);
46}
47
48void backend_set_tls(void *data)
49{
50    pthread_setspecific(pthread_key, data);
51}
52
53void *backend_get_thread(void)
54{
55    return (void *)pthread_self();
56}
57
58static int remote_init(void *dumm)
59{
60    return 0;
61}
62
63void backend_span_domain_default(int nos_threads)
64{
65    /* nop */
66}
67
68void backend_span_domain(int nos_threads, size_t stack_size)
69{
70    /* nop */
71}
72
73void backend_init(void)
74{
75    int r = pthread_key_create(&pthread_key, NULL);
76    if (r != 0) {
77        printf("pthread_key_create failed\n");
78    }
79}
80
81void backend_create_time(int cores)
82{
83    /* nop */
84}
85
86void backend_thread_exit(void)
87{
88}
89
90struct thread *backend_thread_create_varstack(bomp_thread_func_t start_func,
91                                              void *arg, size_t stacksize)
92{
93    start_func(arg);
94    return NULL;
95}
96#endif
97
98struct bomp_state * bomp_get_backend_state_linux(void)
99{
100    return lomp_st;
101}
102
103
104