--- nono/host/hostdevice.cpp 2026/04/29 17:05:18 1.1.1.2 +++ nono/host/hostdevice.cpp 2026/04/29 17:05:30 1.1.1.4 @@ -12,9 +12,10 @@ #include "scheduler.h" // コンストラクタ -HostDevice::HostDevice(int objid_) +HostDevice::HostDevice(Device *parent_, uint objid_) : inherited(objid_) { + parent = parent_; } // デストラクタ @@ -91,18 +92,6 @@ HostDevice::AddListen(int ls, int action return kevent_add(kq, ls, EVFILT_READ, action, LISTEN_SOCKET); } -// コールバック先デバイスを設定。 -// -// コールバックはデバイスと関数が両方設定されている時だけ呼び出すので、 -// 設定時は、コールバック関数設定後に SetCallbackDevice() でデバイスを設定、 -// 解除時は、まず SetCallbackDevice(NULL) でデバイスを解除、 -// の順にすること。 -void -HostDevice::SetCallbackDevice(Device *dev_) -{ - dev = dev_; -} - // 受信通知コールバックを設定 void HostDevice::SetRxCallback(DeviceCallback_t func) @@ -121,6 +110,8 @@ HostDevice::SetAcceptCallback(DeviceCall void HostDevice::ThreadRun() { + SetThreadAffinityHint(AffinityClass::Light); + for (; exit_requested == false; ) { struct kevent kev; int r; @@ -175,8 +166,8 @@ HostDevice::Dispatch(int udata) // キューに1個以上データが投入されたら VM に通知 n = Read(); if (n > 0) { - if (dev && rx_func) { - (dev->*rx_func)(); + if (rx_func) { + (parent->*rx_func)(); } } } @@ -213,11 +204,11 @@ HostDevice::putlogn(const char *fmt, ... int len; uint64 vt = scheduler->GetVirtTime(); - len = snprintf(buf, sizeof(buf), "%4d.%03d'%03d'%03d %s ", - (int)(vt / 1000 / 1000 / 1000), - (int)((vt / 1000 / 1000) % 1000), - (int)((vt / 1000) % 1000), - (int)(vt % 1000), + len = snprintf(buf, sizeof(buf), "%4u.%03u'%03u'%03u %s ", + (uint)(vt / 1000 / 1000 / 1000), + (uint)((vt / 1000 / 1000) % 1000), + (uint)((vt / 1000) % 1000), + (uint)(vt % 1000), GetName().c_str()); va_start(ap, fmt);