thread: store struct msg on the stack instead of in the thread

This commit is contained in:
2026-03-18 20:52:47 +00:00
parent 30c9c9db45
commit 1eef23ea98
2 changed files with 11 additions and 14 deletions

View File

@@ -39,14 +39,11 @@ struct thread {
virt_addr_t tr_cpu_user_sp, tr_cpu_kernel_sp; virt_addr_t tr_cpu_user_sp, tr_cpu_kernel_sp;
struct runqueue *tr_rq; struct runqueue *tr_rq;
struct msg tr_msg;
struct page_request tr_page_req;
struct queue_entry tr_parent_entry; struct queue_entry tr_parent_entry;
struct queue_entry tr_rqentry; struct queue_entry tr_rqentry;
struct vm_page *tr_kstack; struct vm_page *tr_kstack;
struct vm_object *tr_ustack;
}; };
extern struct thread *thread_alloc(void); extern struct thread *thread_alloc(void);

View File

@@ -88,25 +88,25 @@ kern_status_t port_send_msg(
} }
struct thread *self = current_thread(); struct thread *self = current_thread();
struct msg *msg = &self->tr_msg; struct msg msg;
memset(msg, 0x0, sizeof *msg); memset(&msg, 0x0, sizeof msg);
msg->msg_status = KMSG_WAIT_RECEIVE; msg.msg_status = KMSG_WAIT_RECEIVE;
msg->msg_sender_thread = self; msg.msg_sender_thread = self;
msg->msg_sender_port = port; msg.msg_sender_port = port;
memcpy(&msg->msg_req, in_msg, sizeof msg->msg_req); memcpy(&msg.msg_req, in_msg, sizeof msg.msg_req);
memcpy(&msg->msg_resp, out_reply, sizeof msg->msg_req); memcpy(&msg.msg_resp, out_reply, sizeof msg.msg_req);
unsigned long flags; unsigned long flags;
channel_lock_irqsave(port->p_remote, &flags); channel_lock_irqsave(port->p_remote, &flags);
port->p_status = PORT_SEND_BLOCKED; port->p_status = PORT_SEND_BLOCKED;
channel_enqueue_msg(port->p_remote, msg); channel_enqueue_msg(port->p_remote, &msg);
channel_unlock_irqrestore(port->p_remote, flags); channel_unlock_irqrestore(port->p_remote, flags);
wait_for_reply(msg, lock_flags); wait_for_reply(&msg, lock_flags);
channel_lock_irqsave(port->p_remote, &flags); channel_lock_irqsave(port->p_remote, &flags);
btree_delete(&port->p_remote->c_msg, &msg->msg_node); btree_delete(&port->p_remote->c_msg, &msg.msg_node);
channel_unlock_irqrestore(port->p_remote, flags); channel_unlock_irqrestore(port->p_remote, flags);
return msg->msg_result; return msg.msg_result;
} }