<commit_before>#include <fudge.h>
#include "resource.h"
#include "binary.h"
#include "container.h"
#include "task.h"
#include "service.h"
#include "kernel.h"

static struct container containers[KERNEL_CONTAINERS];
static struct task tasks[KERNEL_TASKS];
static struct service services[KERNEL_SERVICES];
static struct list active;
static struct list inactive;
static struct list blocked;

struct task *kernel_findactivetask(void)
{

    return (active.tail) ? active.tail->data : 0;

}

struct task *kernel_findinactivetask(void)
{

    return (inactive.tail) ? inactive.tail->data : 0;

}

void kernel_inactivatetask(struct task *task)
{

    switch (task->state.status)
    {

    case TASK_STATUS_ACTIVE:
        list_move(&inactive, &task->state.item);

        task->state.status = TASK_STATUS_INACTIVE;

        break;

    }

}

void kernel_activatetask(struct task *task)
{

    switch (task->state.status)
    {

    case TASK_STATUS_ACTIVE:
    case TASK_STATUS_INACTIVE:
    case TASK_STATUS_UNBLOCKED:
        list_move(&active, &task->state.item);

        task->state.status = TASK_STATUS_ACTIVE;

        break;

    }

}

void kernel_blocktask(struct task *task)
{

    switch (task->state.status)
    {

    case TASK_STATUS_ACTIVE:
        list_move(&blocked, &task->state.item);

        task->state.status = TASK_STATUS_BLOCKED;

        break;

    }

}

void kernel_unblocktask(struct task *task)
{

    switch (task->state.status)
    {

    case TASK_STATUS_BLOCKED:
    case TASK_STATUS_UNBLOCKED:
        list_move(&active, &task->state.item);

        task->state.status = TASK_STATUS_UNBLOCKED;

        break;

    }

}

struct service *kernel_getservice(struct task *task, unsigned int service)
{

    return &services[task->id * TASK_DESCRIPTORS + (service & (TASK_DESCRIPTORS - 1))];

}

static void copyservice(struct service *tservice, struct service *sservice)
{

    tservice->server = (sservice) ? sservice->server : 0;
    tservice->state.id = (sservice) ? sservice->state.id : 0;
    tservice->state.offset = 0;
    tservice->state.current = 0;

}

void kernel_copyservices(struct task *source, struct task *target)
{

    unsigned int i;

    for (i = 0; i < 8; i++)
    {

        copyservice(kernel_getservice(target, i + 0), kernel_getservice(source, i + 8));
        copyservice(kernel_getservice(target, i + 8), kernel_getservice(source, i + 8));
        copyservice(kernel_getservice(target, i + 16), 0);
        copyservice(kernel_getservice(target, i + 24), 0);

    }

}

unsigned int kernel_unicast(struct task *task, void *buffer, unsigned int count)
{<commit_msg>do not need to initiate to zero<commit_after>#include <fudge.h>
#include "resource.h"
#include "binary.h"
#include "container.h"
#include "task.h"
#include "service.h"
#include "kernel.h"

static struct container containers[KERNEL_CONTAINERS];
static struct task tasks[KERNEL_TASKS];
static struct service services[KERNEL_SERVICES];
static struct list active;
static struct list inactive;
static struct list blocked;

struct task *kernel_findactivetask(void)
{

    return (active.tail) ? active.tail->data : 0;

}

struct task *kernel_findinactivetask(void)
{

    return (inactive.tail) ? inactive.tail->data : 0;

}

void kernel_inactivatetask(struct task *task)
{

    switch (task->state.status)
    {

    case TASK_STATUS_ACTIVE:
        list_move(&inactive, &task->state.item);

        task->state.status = TASK_STATUS_INACTIVE;

        break;

    }

}

void kernel_activatetask(struct task *task)
{

    switch (task->state.status)
    {

    case TASK_STATUS_ACTIVE:
    case TASK_STATUS_INACTIVE:
    case TASK_STATUS_UNBLOCKED:
        list_move(&active, &task->state.item);

        task->state.status = TASK_STATUS_ACTIVE;

        break;

    }

}

void kernel_blocktask(struct task *task)
{

    switch (task->state.status)
    {

    case TASK_STATUS_ACTIVE:
        list_move(&blocked, &task->state.item);

        task->state.status = TASK_STATUS_BLOCKED;

        break;

    }

}

void kernel_unblocktask(struct task *task)
{

    switch (task->state.status)
    {

    case TASK_STATUS_BLOCKED:
    case TASK_STATUS_UNBLOCKED:
        list_move(&active, &task->state.item);

        task->state.status = TASK_STATUS_UNBLOCKED;

        break;

    }

}

struct service *kernel_getservice(struct task *task, unsigned int service)
{

    return &services[task->id * TASK_DESCRIPTORS + (service & (TASK_DESCRIPTORS - 1))];

}

static void copyservice(struct service *tservice, struct service *sservice)
{

    tservice->server = (sservice) ? sservice->server : 0;
    tservice->state.id = (sservice) ? sservice->state.id : 0;

}

void kernel_copyservices(struct task *source, struct task *target)
{

    unsigned int i;

    for (i = 0; i < 8; i++)
    {

        copyservice(kernel_getservice(target, i + 0), kernel_getservice(source, i + 8));
        copyservice(kernel_getservice(target, i + 8), kernel_getservice(source, i + 8));
        copyservice(kernel_getservice(target, i + 16), 0);
        copyservice(kernel_getservice(target, i + 24), 0);

    }

}

unsigned int kernel_unicast(struct task *task, void *buffer, unsigned int count)
{
{'fraction_non_alphanumeric': 0.11812391430225826, 'fraction_numerical': 0.006948465547191662, 'mean_word_length': 3.425277540563621, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '615757', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1728, 'n_words': 382}