Exemplo n.º 1
0
/*! @brief Starts a new process. */
refos_err_t
proc_new_proc_handler(void *rpc_userptr , char* rpc_name , char* rpc_params , bool rpc_block ,
                      int32_t rpc_priority , int32_t* rpc_status)
{
    struct proc_pcb *pcb = (struct proc_pcb*) rpc_userptr;
    assert(pcb->magic == REFOS_PCB_MAGIC);
    
    if (!rpc_name) {
        return EINVALIDPARAM;
    }

    /* Kick off an instance of selfloader, which will do the actual process loading work. */
    int error = proc_load_direct("selfloader", rpc_priority, rpc_name, pcb->pid, 0x0);
    if (error != ESUCCESS) {
        ROS_WARNING("failed to run selfloader for new process [%s].", rpc_name);
        return error;
    }

    /* Optionally block parent process until child process has finished. */
    if (rpc_block) {
        /* Save the reply endpoint. */
        proc_save_caller(pcb);
        pcb->parentWaiting = true;
        pcb->rpcClient.skip_reply = true;
        return ESUCCESS;
    }

    /* Immediately resume the parent process. */
    return ESUCCESS;
}
Exemplo n.º 2
0
/*! @brief Helper function to delegate fault message to an external endpoint.
    
    Writes the given message to the delegator's notification ring buffer,  and then sends an async
    notification along the EP the delegator has set up previously.  This helper function is used for
    every kind of notification.

    @param f The fault message info structure.
    @param delegationPCB The PCB structure of the delegator recieving the notification.
    @param delegationEP The async endpoint of delegator to notify.
    @param vmFaultNotification The VM fault noficfiation message contents.
    @param saveReply Whether to save the falunt client's reply EP.
*/
static void
fault_delegate_notification(struct procserv_vmfault_msg *f, struct proc_pcb *delegationPCB,
        cspacepath_t delegationEP, struct proc_notification vmFaultNotification, bool saveReply)
{
    assert(f && f->pcb);
    assert(delegationPCB && delegationPCB->magic == REFOS_PCB_MAGIC);

    if (!delegationPCB->notificationBuffer) {
        printf("PID notif buffer NULL! %d\n", delegationPCB->pid);
        output_segmentation_fault("Delegator dataspace server has no notification buffer.", f);
        return;
    }

    /* Save the caller reply cap to reply to later. */
    if (saveReply) {
        int error = proc_save_caller(f->pcb);
        if (error) {
            output_segmentation_fault("Failed to save caller reply cap.", f);
            return;
        }
    }

    /* Append notification to pager's notification buffer. */
    int error = rb_write(delegationPCB->notificationBuffer, (char*)(&vmFaultNotification),
            sizeof(vmFaultNotification));
    if (error) {
        output_segmentation_fault("Failed to write VM fault notification to buffer.", f);
        return;
    }

    /* Notify the pager of this fault. */
    dispatcher_notify(delegationEP.capPtr);
}