I create a two threads and used a global variable to communicate between them but it failed. I want to know that if each thread is a different process or a sub threads in a single process.
Different from PC OS,it's hard to describe the rt-thread's thread is a process or a sub-threads, these points may help you understand it:
@DH04 The above part of the code is the code I am using the variable data is declared in global. After the thread1 the thread2 is not running. But usually I work like this in PC OS.
@DH04 What scheduling technique is used for multi-threads. ?
@varun 8, 32 or 256 priority scheduling multi-thread scheduling. And using the round-robin policy ensures that all threads having the same priority level will be scheduled equally.
So please check the priority and tick parameters of both the thread1 and thread2.
Or so you could try to add some delay after while like this:
@varun ,as @luckydarcy said, your code may has some logic problems,in thread1_entry and thread2_entry ,you didn't give up the cpu if the condition not met, so the problem will disappear if you can ensure the process will give up the cpu wheathre the data==1 or not