Jump to content

Imeediate notification error


ashwathgan

Recommended Posts

Hi all

 

I have a SystemC thread.

 

I create two instances of this thread in main ( so, now two threads are ready to run)

 

What I tired was to randomize the execution order of these two threads, hence i used a event.notify()

 

But when I do that, i get the warning "immediate Self Notification ignored"

 

Where am I going wrong?

 

 

 

 

 

thanks in advance

 

 

 

 

 

regards

Ashwath

Link to comment
Share on other sites

Hi.

 

event.notify() is so-called immediate notification.

I.e., the event is notified in the same (current) delta cycle.

When you use this kind of notification in a process that is sensitive to that event, this usually makes no sense. The state of signals cannot change during one dalta cycle. Hence, this will (or might) lead to endless executions of this process without reaching the next delta at any time.

 

Greetings

Ralph

Link to comment
Share on other sites

Thank you Ralph.

 

I understand. But i want to achieve something like the following

 

I have thread A which can start immediately after start of simulation(sc_start()) and it takes 5 time period to complete

I have thread B which can also start immediately after start of simulation and takes 5 time period

 

Though A and B can potentialy start and run at the same time, i wanted to achieve a random interleaving of both these threads . For example, thread A must start at 0 and run till 5 through wait(time_period,SC_NS) and again runs till 10ns. Till now b must be blocked, so now B blocks A and runs for number of times and A starts back again

 

 

 

 

Regards

Ashwath

Link to comment
Share on other sites

Hi.

 

'Unfortunately', there is no randomness in the execution order of processes within the same delta cycle.

http://forums.accellera.org/topic/5052-accellera-kernel-process-order/#entry12122

 

When the two threads start at the same time and have the same period, they will run always in the same order. This is part of the SystemC implementation and cannot be changed without changing the SystemC kernel. There are some approaches about this, patches for the SystemC kernel to add randomness in the execution order, but I do not know the current status of them.

E.g.:

http://www.teisa.unican.es/HetSC/downloads/SC_kernel_Improvements/uc_rand_sched/Patch_Kernel_sc_pseudorandom_sched_Eng.pdf

 

If you do not communicate via signal and you do not have dependencies on the delta cycle, you can move the execution of the threads to the next delta cycle by adding a 'wait(SC_ZERO_TIME)' and execute in random cases.

 

Greetings

Ralph

Link to comment
Share on other sites

Thank you Ralph.

 

I understand. But i want to achieve something like the following

 

I have thread A which can start immediately after start of simulation(sc_start()) and it takes 5 time period to complete

I have thread B which can also start immediately after start of simulation and takes 5 time period

 

Though A and B can potentialy start and run at the same time, i wanted to achieve a random interleaving of both these threads . For example, thread A must start at 0 and run till 5 through wait(time_period,SC_NS) and again runs till 10ns. Till now b must be blocked, so now B blocks A and runs for number of times and A starts back again

 

 

 

 

Regards

Ashwath

Hello Sir,

Thread scheduling is controlled by the underlying operating

system and the application programmer has no control on

the activities of the thread scheduler. So which of two threads

A or B will be invoked at start cannot be predicted. Threads

use shared memory, and only the operating system has the

privileges to control memory allocation/deallocation. Hope

that helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...