Re: l4/sys/syscalls.h: No such file or directory

Valentin Hauner <[email protected]>
Newsgroups gmane.comp.micro-kernel.l4.devel
Message-ID <[email protected]>
Hi,

On 08/20/2014 07:53 PM, Björn Döbel wrote:
> In the second case (PC == 0) that won't work. This looks like someone
> already performed a jmp/call to address 0. Here you will have to
> figure out where things go wrong using printf()s. (Or GDB in the qemu
> scenario...)
>
> Does that help?
>   
Yes, a bit. I decided to debug it with jdb. I've attached the jdb output
as well as the main.c with the source code. It's a very small and simple
example. The function 'create_edf_thread' matches largely with the main
function of your utcb-ipc example, it just sets a different scheduling
parameter (deadline based).

Concerning the thread list output, those with id's 25 and 26 are the
ones executing the functions thread1() respectively thread2() in main.c.
I'm not sure what the state 'exc_progr' means for them in this context.
1b is #threadipc itself, 1e seems to be the main thread of it (but I'm
not sure of that).

Does your trained eye see the cause of this error?

Best regards,
Valentin

_______________________________________________
l4-hackers mailing list
[email protected]
http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers
jdb_trace.txt (text/plain, 1.6 KB)
-- Everything went normal until here, now entering jdb with enter_kdebug()

    ---------------------------------------------------------------------      
    CPU 0 [0100043f]: INT 3
jdb: jb
    ---------------------------------------------------------------------      
    CPU 0 [01000441]: Branch/Call
jdb: jb
    ---------------------------------------------------------------------      
    CPU 0 [01000444]: Branch/Call
jdb: jb
    ---------------------------------------------------------------------      
    CPU 0 [01000445]: Branch/Call
jdb: jb
    ---------------------------------------------------------------------      
    CPU 0 [00000000]: Branch/Call

jdb: I+
IPC logging enabled (exit with 'i', proceed with other key)
jdb: jb

ipc: 001b send->[C:9001] DID=2 L=0 [Klog200d] (00000000,0000002c) TO=INF
L4Re[rm]: unhandled read page fault @0 pc=0
ipc: 001b repl->[C:INV] DID=26 L=0 [00000001] (ffffffff,00000000) TO=0/INF
ipc: 001b send->[C:9001] DID=2 L=0 [Klog200b] (00000000,00000022) TO=INF
L4Re: unhandled exception: pc=0x0
ipc: 001b wait->[C:INV] DID=1b L=0 TO=INF

[      #threadipc] jdb: lp
   id  cpu    name             pr     sp  wait    to state
   26   0     -----             0     1a    1b       ready,rcv_wait,exc_progr
   25   0     -----             0     1a    1b       rcv_wait,exc_progr
   1e   0     -----             2     1a     a       rcv_wait
   1b   0     #threadipc       ff     1a             ready
    a   0     moe              ff      9     -       rcv_wait
    8   0     sigma0            1      7     -       rcv_wait
    6   0     -----             0      1             ready
main.c (text/x-csrc, 2.6 KB)
/**
 * \file
 * \brief Example of creating threads for the EDF scheduler
 *
 * This example shows how threads owning a deadline are created for the EDF scheduler.
 * It's adapted from the utcb-ipc example by Adam Lackorzynski, Alexander Warg and Björn Döbel.
 */
/* 
 *
 * (c) 2014 Valentin Hauner <[email protected]>
 *
 * This file is distributed under the terms of the
 * GNU General Public License 2.
 * Please see the COPYING-GPL-2 file for details.
 */
#include <l4/sys/ipc.h>
#include <l4/sys/thread.h>

#include <l4/sys/factory.h>
#include <l4/sys/utcb.h>
#include <l4/re/env.h>
#include <l4/re/c/util/cap_alloc.h>

#include "l4/sys/kdebug.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define ANSI_COLOR_RED     "\x1b[31m"
#define ANSI_COLOR_GREEN   "\x1b[32m"
#define ANSI_COLOR_YELLOW  "\x1b[33m"
#define ANSI_COLOR_BLUE    "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN    "\x1b[36m"
#define ANSI_COLOR_RESET   "\x1b[0m"

static unsigned char *thread_stacks[20];
static l4_cap_idx_t   thread_caps[20];
static unsigned       count = 0;

static void thread1(void)
{
  int i;
  for (i = 0; i < 10; i++)
  {
    printf(ANSI_COLOR_BLUE "Thread 1: Hello World %d!" ANSI_COLOR_RESET "\n", i);
  }
}

static void thread2(void)
{
  int j;
  for (j = 0; j < 10; j++)
  {
    printf(ANSI_COLOR_GREEN "Thread 2: Hello World %d!" ANSI_COLOR_RESET "\n", j);
  }

  enter_kdebug();
}

static int create_edf_thread(void *func, unsigned deadline) {
  thread_stacks[count] = malloc(8 << 10);

  l4_msgtag_t tag;
  l4_cap_idx_t thread_cap = l4re_util_cap_alloc();

  if (l4_is_invalid_cap(thread_cap))
    return -1;

  tag = l4_factory_create_thread(l4re_env()->factory, thread_cap);
  if (l4_error(tag))
    return -1;

  l4_thread_control_start();
  l4_thread_control_pager(l4re_env()->rm);
  l4_thread_control_exc_handler(l4re_env()->rm);
  l4_thread_control_bind((l4_utcb_t *)l4re_env()->first_free_utcb,
                          L4RE_THIS_TASK_CAP);
  tag = l4_thread_control_commit(thread_cap);
  if (l4_error(tag))
    return -2;

  tag = l4_thread_ex_regs(thread_cap,
                          (l4_umword_t)func,
                          (l4_umword_t)(thread_stacks[count] + sizeof(thread_stacks[count])), 0);
  if (l4_error(tag))
    return -3;

  l4_sched_param_t sp = l4_sched_param_by_type(Deadline, deadline, 0);
  tag = l4_scheduler_run_thread(l4re_env()->scheduler, thread_cap, &sp);
  if (l4_error(tag))
    return -4;

  thread_caps[count] = thread_cap;

  return count++;
}

int main(void)
{
  create_edf_thread(thread1, 1);
  create_edf_thread(thread2, 3);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.