Resurrecting some of the logging in rust_chan.cpp

This commit is contained in:
Eric Holk 2011-07-27 16:33:31 -07:00
parent 9ea8476faa
commit b85dee8d5b
3 changed files with 35 additions and 30 deletions

View File

@ -13,14 +13,14 @@ rust_chan::rust_chan(rust_kernel *kernel, maybe_proxy<rust_port> *port,
if (port) { if (port) {
associate(port); associate(port);
} }
// DLOG(task->sched, comm, "new rust_chan(task=0x%" PRIxPTR KLOG(kernel, comm, "new rust_chan(task=0x%" PRIxPTR
// ", port=0x%" PRIxPTR ") -> chan=0x%" PRIxPTR, ", port=0x%" PRIxPTR ") -> chan=0x%" PRIxPTR,
// (uintptr_t) task, (uintptr_t) port, (uintptr_t) this); (uintptr_t) task, (uintptr_t) port, (uintptr_t) this);
} }
rust_chan::~rust_chan() { rust_chan::~rust_chan() {
// DLOG(kernel->sched, comm, "del rust_chan(task=0x%" PRIxPTR ")", KLOG(kernel, comm, "del rust_chan(task=0x%" PRIxPTR ")",
// (uintptr_t) this); (uintptr_t) this);
// A(kernel->sched, is_associated() == false, // A(kernel->sched, is_associated() == false,
// "Channel must be disassociated before being freed."); // "Channel must be disassociated before being freed.");
@ -33,9 +33,9 @@ void rust_chan::associate(maybe_proxy<rust_port> *port) {
this->port = port; this->port = port;
if (port->is_proxy() == false) { if (port->is_proxy() == false) {
scoped_lock with(port->referent()->lock); scoped_lock with(port->referent()->lock);
// DLOG(kernel->sched, task, KLOG(kernel, task,
// "associating chan: 0x%" PRIxPTR " with port: 0x%" PRIxPTR, "associating chan: 0x%" PRIxPTR " with port: 0x%" PRIxPTR,
// this, port); this, port);
++this->ref_count; ++this->ref_count;
this->task = port->referent()->task; this->task = port->referent()->task;
this->task->ref(); this->task->ref();
@ -56,9 +56,9 @@ void rust_chan::disassociate() {
if (port->is_proxy() == false) { if (port->is_proxy() == false) {
scoped_lock with(port->referent()->lock); scoped_lock with(port->referent()->lock);
// DLOG(kernel->sched, task, KLOG(kernel, task,
// "disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR, "disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR,
// this, port->referent()); this, port->referent());
--this->ref_count; --this->ref_count;
task->deref(); task->deref();
this->task = NULL; this->task = NULL;
@ -98,7 +98,7 @@ void rust_chan::send(void *sptr) {
buffer.dequeue(NULL); buffer.dequeue(NULL);
} else { } else {
if (target_port->task->blocked_on(target_port)) { if (target_port->task->blocked_on(target_port)) {
// DLOG(sched, comm, "dequeued in rendezvous_ptr"); KLOG(kernel, comm, "dequeued in rendezvous_ptr");
buffer.dequeue(target_port->task->rendezvous_ptr); buffer.dequeue(target_port->task->rendezvous_ptr);
target_port->task->rendezvous_ptr = 0; target_port->task->rendezvous_ptr = 0;
target_port->task->wakeup(target_port); target_port->task->wakeup(target_port);

View File

@ -1,11 +1,7 @@
#include "rust_internal.h" #include "rust_internal.h"
#define KLOG(...) \ #define KLOG_(...) \
do { \ KLOG(this, kern, __VA_ARGS__)
if (log_rt_kern >= log_note) { \
log(log_note, __VA_ARGS__); \
} \
} while (0)
rust_kernel::rust_kernel(rust_srv *srv, size_t num_threads) : rust_kernel::rust_kernel(rust_srv *srv, size_t num_threads) :
_region(srv, true), _region(srv, true),
@ -32,8 +28,8 @@ rust_kernel::create_scheduler(int id) {
rust_handle<rust_scheduler> *handle = internal_get_sched_handle(sched); rust_handle<rust_scheduler> *handle = internal_get_sched_handle(sched);
message_queue->associate(handle); message_queue->associate(handle);
message_queues.append(message_queue); message_queues.append(message_queue);
KLOG("created scheduler: " PTR ", id: %d, index: %d", KLOG_("created scheduler: " PTR ", id: %d, index: %d",
sched, id, sched->list_index); sched, id, sched->list_index);
_kernel_lock.signal_all(); _kernel_lock.signal_all();
_kernel_lock.unlock(); _kernel_lock.unlock();
return sched; return sched;
@ -42,7 +38,7 @@ rust_kernel::create_scheduler(int id) {
void void
rust_kernel::destroy_scheduler(rust_scheduler *sched) { rust_kernel::destroy_scheduler(rust_scheduler *sched) {
_kernel_lock.lock(); _kernel_lock.lock();
KLOG("deleting scheduler: " PTR ", name: %s, index: %d", KLOG_("deleting scheduler: " PTR ", name: %s, index: %d",
sched, sched->name, sched->list_index); sched, sched->name, sched->list_index);
sched->message_queue->disassociate(); sched->message_queue->disassociate();
rust_srv *srv = sched->srv; rust_srv *srv = sched->srv;
@ -166,14 +162,14 @@ rust_kernel::start_kernel_loop() {
void void
rust_kernel::run() { rust_kernel::run() {
KLOG("started kernel loop"); KLOG_("started kernel loop");
start_kernel_loop(); start_kernel_loop();
KLOG("finished kernel loop"); KLOG_("finished kernel loop");
} }
void void
rust_kernel::terminate_kernel_loop() { rust_kernel::terminate_kernel_loop() {
KLOG("terminating kernel loop"); KLOG_("terminating kernel loop");
_interrupt_kernel_loop = true; _interrupt_kernel_loop = true;
signal_kernel_lock(); signal_kernel_lock();
join(); join();
@ -190,16 +186,16 @@ rust_kernel::~rust_kernel() {
// messages. // messages.
pump_message_queues(); pump_message_queues();
KLOG("freeing handles"); KLOG_("freeing handles");
free_handles(_task_handles); free_handles(_task_handles);
KLOG("..task handles freed"); KLOG_("..task handles freed");
free_handles(_port_handles); free_handles(_port_handles);
KLOG("..port handles freed"); KLOG_("..port handles freed");
free_handles(_sched_handles); free_handles(_sched_handles);
KLOG("..sched handles freed"); KLOG_("..sched handles freed");
KLOG("freeing queues"); KLOG_("freeing queues");
rust_message_queue *queue = NULL; rust_message_queue *queue = NULL;
while (message_queues.pop(&queue)) { while (message_queues.pop(&queue)) {
@ -228,7 +224,7 @@ rust_kernel::free_handles(hash_map<T*, rust_handle<T>* > &map) {
T* key; T* key;
rust_handle<T> *value; rust_handle<T> *value;
while (map.pop(&key, &value)) { while (map.pop(&key, &value)) {
KLOG("...freeing " PTR, value); KLOG_("...freeing " PTR, value);
delete value; delete value;
} }
} }

View File

@ -23,6 +23,15 @@ const uint32_t log_note = 1;
} \ } \
} while (0) } while (0)
#define KLOG(k, field, ...) \
KLOG_LVL(k, field, log_note, __VA_ARGS__)
#define KLOG_LVL(k, field, lvl, ...) \
do { \
if (log_rt_##field >= lvl) { \
(k)->log(lvl, __VA_ARGS__); \
} \
} while (0)
struct rust_scheduler; struct rust_scheduler;
struct rust_task; struct rust_task;