public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Leschke Serafin (lesc)" <lesc@zhaw.ch>
To: "ecos-discuss@ecos.sourceware.org" <ecos-discuss@ecos.sourceware.org>
Subject: [ECOS] cyg_thread_delay vs cyg_flag_wait behavior
Date: Fri, 17 Oct 2014 15:14:00 -0000	[thread overview]
Message-ID: <A8860DB164AE7544A8A583D32ED149BA045B7090@srv-mail-121.zhaw.ch> (raw)

hi and sorry to awake this zombie but I could not find anything other
then this old thread relating to my problem:


I have a programm (part of a driver ethernet driver) wich is needed to
do some perodic duties (sending special packets) and waiting for events
(handling special packets wich are not to be deleviered to the OS).
Waiting for this events is realised via flags because I get only one
interrupt for all packet and events ariving.

My Code loocks something like this:

initalize_threads(){
    /*init timer thread this is only used to create the timer so it can
has a custom priority*/
    cyg_thread_create(TIMER_PRIOROTY,
                      initialize_timer,
                      0,
                      "timer thread",
                      timer_stack,
                      TIMER_STACK_SIZE,
                      &timer_thread_hdl,
                      &timer_thread_obj);
    cyg_thread_resume(timer_thread_hdl);

    /*init irq dispatcher thread*/
    cyg_thread_create(DISPATCHER_PRIOROTY,
                      irq_dispatcher,
                      0,
                      "dispatcher thread",
                      dispatcher_stack,
                      DISPATCHER_STACK_SIZE,
                      &dispatcher_hdl,
                      &dispatcher_obj);
    cyg_thread_resume(dispatcher_hdl);
}

initialize_timer(cyg_addrword_t data){
     sys_clk= cyg_real_time_clock();
    cyg_clock_to_counter(sys_clk, &counter_hld);
    cyg_alarm_create(delay_req_counter_hld,
                    timer_handler,
                    (cyg_addrword_t)&_index,
                    &alarm_hld,
                    &alarm);
    cyg_alarm_initialize(alarm_hld,
                         START_DELAY,
                         TIMER_INTERVAL);
}

timer_handler(cyg_handle_t delay_req_alarm_hld,
                             cyg_addrword_t data){
        printf("WORKS!");
}

irq_dispatcher(cyg_addrword_t data){
    cyg_uint32 flags = 0;
    while (1){
        /*This do-while is not really imperative, it's just for the case
that the thread is woken up force-fully, which is probably never*/
        do{
            /* if I put a cyg_thread_delay() here everything works */
            flags = cyg_flag_wait(&isr_flags,PTCP_IRQ_FLAGS,
CYG_FLAG_WAITMODE_OR);
        }while(! flags);
        {
            /*Handling the events*/
          }
}

The Problem now is this only works if TIMER_PRIOROTY <
DISPATCHER_PRIOROTY otherwise the timer_handler is never called. On the
other hand it works if i put a cyg_thread_delay before my wait.

I hope I stated my problem clear, this is my first ecos project and I
still have quite a lot of trouble with it.

best regards Serafin

-- 
Serafin Leschke, BSc in Computer Sience UAS Zurich
Research Assistant

ZHAW, Zurich University of Applied Sciences
InES, Institute of Embedded Systems
Postfach
Technikumstr. 22
CH-8401 Winterthur
--
Tel: +41 58 934 69 79
Fax: +41 58 935 76 87
E-Mail: serafin.lescke@zhaw.ch
Web: http://ines.zhaw.ch
--


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

             reply	other threads:[~2014-10-17 15:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-17 15:14 Leschke Serafin (lesc) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-06-19 13:07 Chase, Tom
2006-06-19 17:20 ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A8860DB164AE7544A8A583D32ED149BA045B7090@srv-mail-121.zhaw.ch \
    --to=lesc@zhaw.ch \
    --cc=ecos-discuss@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).