"Xiao Tao, how many other things do you think I was joking about train tickets, plane tickets, and Mm? You are dancing in front of your eyes, and you are not finishing the dance ..."
"Ah? How can this problem be solved? In a dormitory, the difference between people is so big. I don't study well at ordinary times. If I have any questions, I will give you free teaching and complain, too many friends .... "I hammer the table and say.
"My friends, I'm not enough friends. Haven't you heard of me? My friend is me, I am a friend, and I have two knives .. "Mr. Wang interrupted me." It's been three hours since you listened to the Scriptures. You see, it's five times. Why do you still want to compete with Yi's Three Kingdoms .."
I think I'm speechless, and the sun rises and falls, and the flowers do not know how many times they have opened, so I am too lazy to care about me, I am also wondering why I can't finish this concurrency control .. there are other wonderful things in the future. You can't just stop John's head here ..." Well, you don't have to be confused. I swear, I swear to the light. If this section is still endless, I will solve your issue of GF, not yet "I am helpless.
"This feeling is good." Upon hearing MM's topic, Mr. Smith was always passionate and had no choice but to be a man.
Back to the truth, saying...
Tip 10: Read and Write semaphores (no, it's all ten. No wonder John is impatient. There are so many tricks. It's pretty much like you. I'm not so quick at 9 Yang's power protection yet)
"Mr. Wang, do you remember? I mentioned a trick in front of him: Anti-read, anti-write... "
"Remember, if there is mm, I will remember it. If there is no such thing, it's easy to say..."
"Well, don't ask you, leave xxx with three words"
Legend has it that a read/write semaphore allows N read execution units to access Shared resources at the same time, but only one write execution unit can be allowed at most.
"I think of it, I think of it, that is, what is it with the front-end-anti-attack ..... Almost ..." Think about how long the sub-account of Mr. Wang hangs. I am so lazy about him ..
Usage: 1) Define and initialize the read/write semaphores
Struct rw_semphore my_rws; // defines the read/write semaphore.
Void init_rwsem (struct rw_semaphore * SEM); // initialize the read/write semaphore
2) read semaphore acquisition
Void down_read (struct rw_semaphore * SEM );
Int down_read_try (struct rw_semaphore * SEM );
3) release the read semaphore
Void up_read (struct rw_semaphore * SEM );
4) obtain the write semaphore
Void down_write (struct rw_semaphore * SEM );
Int down_write_try (struct rw_semaphore * SEM );
5) release the write semaphore
Void up_write (struct rw_semaphore * SEM );
Here is an example:
Rw_semaphore rw_sem;// Define the read/write semaphoreInit_rwsem (& rw_sem );// Initialize the read/write semaphore// Obtain the semaphore during readingDown_read (& rw_sem );...// Critical resourceUp_read (& rw_sem );// Obtain the semaphore when writingDown_write (& rw_sem );...// Critical resourceUp_write (& rw_sem );
To be honest, if I find a mm for Mr. Wang, I still have no idea. So, let's say the last move, and I will be relieved...
Tip 11: mutex (what is mutex? How does one feel that the front side is mutex? Oh, indeed, but Linux developers think that they are not addicted, so they have devoted themselves to studying a mutex, who asked us to use people's stuff)
Usage: 1) Define and initialize the mutex
Struct mutex my_mutex;
Mutex_init (& my_mutex );
2) obtain the mutex
Void fastcall mutex_lock (struct mutex * Lock); // The sleep cannot be interrupted.
Int fastcall mutex_lock_interruptible (struct mutex * Lock); // can be interrupted
Int fastcall mutex_lock_trylock (struct mutex * Lock); // try to get it. If it is not obtained, the process will not sleep.
3) release mutex
Void fastcall mutex_unlock (struct mutex * Lock );
Here is an example:
Struct mutex my_mutex; // defines mutex
Mutex_init (& my_mutex );
Mutex_lock (& my_mutex );
.... // Critical resource
Mutex_unlock (& my_mutex );
After all, everything is done, and all the concurrent control-related tricks are done, Mr. Smith should be able to follow mm with confidence. I have these tricks to see who can compete, I don't have to worry about it. I finally finished talking about things that shouldn't have been done in this episode ..
If necessary, I will tell you a section about the character device driver loaded with concurrency control.ProgramI have thought about the name. please raise your hand if you need it ..
Sorry, how can we make advertisements without getting wet...