void * thread1 (void){ printf(1, "I went to sleep %d\n", kthread_id()); kthread_mutex_lock(lock); kthread_cond_wait(cond, lock); printf(1, "im came alive!! %d\n", kthread_id()); kthread_mutex_unlock(lock); kthread_exit(); return (void *) 0; }
PollChannel::~PollChannel() { ScopedLock lock(&channel_lock); // TODO: Is this the correct error to signal with? SignalUnlocked(POLLHUP); // Note: We can't stop early in case of a signal, because that would mean // other threads are still using our data, and since this is the destructor, // leaving early _will_ cause data corruption. Luckily, this loop will // terminate because everyone is now woken up and will cancel, which is what // we wait for to finish. No new requests can come, since we are the // destructor - whoever owns this object is no longer using it. while ( first ) kthread_cond_wait(&no_pending_cond, &channel_lock); }