Quantcast
Channel: SystemC Language Forum RSS Feed
Viewing all articles
Browse latest Browse all 595

Process Synchronisation issue

$
0
0

Hello experts

 

I have a tricky synchronisation to achieve in one model. Here I have two thread processes, The IInd one is waiting for an event which is notified by Ist thread. Here after the event notification from Ist process, I wait for one delta cycle to allow IInd one to come out of wait and do some stuff before Ist one proceed. But what I am abserving that after the wait in Ist process, in next delta cycle both process becomes ready to run and scheduler may pick them in any order but I want IInd process  to run before Ist one. I may use another wait but is there any another way to achieve this ?

 

Here is one simple examle to show this issue

 

In the below example, I am getting the following output

P3

P6

I am expecting

P3

P6

 

#include "systemc.h"

SC_MODULE(event_trial){
    public:
    sc_event se;
    SC_CTOR(event_trial) {
 SC_THREAD(process1);
 SC_THREAD(process2);
    }

    void process1(){
 wait(SC_ZERO_TIME);
 se.notify(SC_ZERO_TIME);
 wait(SC_ZERO_TIME);
 cout<<"P3"<<endl;
    }

    void process2(){
 wait(se);
 cout<<"P6"<<endl;
    }
};

int sc_main(int , char**){
    event_trial et("et");
    sc_start();
    return 0;
}

 

Can anyone suggest a recommended way to achieve the desired output

 

Thanks

Rahul

 


Viewing all articles
Browse latest Browse all 595

Trending Articles