add memory usage
This commit is contained in:
@@ -31,7 +31,6 @@ Modification:
|
||||
|
||||
#include "list.h"
|
||||
#include "memlayout.h"
|
||||
#include "spinlock.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -70,7 +69,6 @@ struct KFreeList {
|
||||
struct KBuddy {
|
||||
uintptr_t n_pages;
|
||||
uintptr_t use_lock;
|
||||
struct spinlock lock;
|
||||
struct KFreeList free_list[MAX_BUDDY_ORDER];
|
||||
struct KPage* first_page;
|
||||
uintptr_t mem_start;
|
||||
|
||||
@@ -29,13 +29,22 @@ Modification:
|
||||
*************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "pagetable.h"
|
||||
#include "actracer.h"
|
||||
#include "rbtree.h"
|
||||
|
||||
struct MemUsage {
|
||||
TraceTag tag;
|
||||
RbtNode* mem_block_root;
|
||||
};
|
||||
|
||||
bool module_phymem_init();
|
||||
char* kalloc(size_t size);
|
||||
bool kfree(char* vaddr);
|
||||
bool raw_kfree(char* paddr);
|
||||
|
||||
void* kalloc_by_ownership(TraceTag owner, uintptr_t size);
|
||||
bool kfree_by_ownership(TraceTag owner, void* vaddr);
|
||||
|
||||
char* raw_alloc(size_t size);
|
||||
bool raw_free(char* paddr);
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ Modification:
|
||||
#include "actracer.h"
|
||||
#include "bitmap64.h"
|
||||
#include "buddy.h"
|
||||
#include "kalloc.h"
|
||||
#include "list.h"
|
||||
|
||||
struct TopLevelPageDirectory {
|
||||
@@ -48,6 +49,9 @@ struct ThreadStackPointer {
|
||||
struct MemSpace {
|
||||
/* trace node */
|
||||
TraceTag tag;
|
||||
/* mem usage info */
|
||||
struct MemUsage mem_usage;
|
||||
|
||||
/* task memory resources */
|
||||
struct TopLevelPageDirectory pgdir; // [phy] vm pgtbl base address
|
||||
uintptr_t heap_base; // mem size of proc used(allocated by kernel)
|
||||
@@ -63,7 +67,7 @@ struct MemSpace {
|
||||
struct Thread* thread_to_notify;
|
||||
};
|
||||
|
||||
struct MemSpace* alloc_memspace();
|
||||
struct MemSpace* alloc_memspace(char* name);
|
||||
void free_memspace(struct MemSpace* pmemspace);
|
||||
uintptr_t* load_memspace(struct MemSpace* pmemspace, char* img_start);
|
||||
struct ThreadStackPointer load_user_stack(struct MemSpace* pmemspace, char** argv);
|
||||
struct ThreadStackPointer load_user_stack(struct MemSpace* pmemspace, char** argv);
|
||||
|
||||
@@ -29,10 +29,12 @@ Modification:
|
||||
*************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "actracer_tag.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct slab_state {
|
||||
TraceTag owner_tag;
|
||||
struct slab_state *prev, *next;
|
||||
uint64_t bitmap;
|
||||
uintptr_t refcount;
|
||||
@@ -40,6 +42,7 @@ struct slab_state {
|
||||
};
|
||||
|
||||
struct slab_allocator {
|
||||
|
||||
size_t element_size;
|
||||
size_t nr_elements;
|
||||
size_t slabsize;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "actracer.h"
|
||||
|
||||
// CLRS
|
||||
// Insertion and Deletion in a Red Black Tree
|
||||
enum rbt_type {
|
||||
RED,
|
||||
BLACK
|
||||
};
|
||||
|
||||
typedef struct RbtNode {
|
||||
uintptr_t key;
|
||||
void* data;
|
||||
struct RbtNode* left;
|
||||
struct RbtNode* right;
|
||||
struct RbtNode* parent;
|
||||
enum rbt_type color;
|
||||
} RbtNode;
|
||||
|
||||
struct RbtNode* rbt_insert(struct RbtNode* T, uintptr_t key, void* data);
|
||||
struct RbtNode* rbt_delete(struct RbtNode* T, struct RbtNode* z);
|
||||
struct RbtNode* rbt_search(struct RbtNode* root, int x);
|
||||
|
||||
void preorder(struct RbtNode* root);
|
||||
void levelorder(struct RbtNode* root);
|
||||
|
||||
void module_rbt_factory_init(TraceTag* _softkernel_tag);
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
/**
|
||||
* @file scheduler.h
|
||||
* @brief scheduler algorithm declaration
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023.08.25
|
||||
*/
|
||||
|
||||
/*************************************************
|
||||
File name: scheduler.h
|
||||
Description: scheduler algorithm declaration
|
||||
Others:
|
||||
History:
|
||||
1. Date: 2023-08-28
|
||||
Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
1. first version
|
||||
*************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "task.h"
|
||||
|
||||
struct Thread* max_priority_runnable_task(void);
|
||||
struct Thread* round_robin_runnable_task(uint32_t priority);
|
||||
void recover_priority(void);
|
||||
@@ -1,36 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
/**
|
||||
* @file scheduler.h
|
||||
* @brief scheduler algorithm declaration
|
||||
* @version 3.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2023.08.25
|
||||
*/
|
||||
|
||||
/*************************************************
|
||||
File name: scheduler.h
|
||||
Description: scheduler algorithm declaration
|
||||
Others:
|
||||
History:
|
||||
1. Date: 2023-08-28
|
||||
Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
1. first version
|
||||
*************************************************/
|
||||
#pragma once
|
||||
#include "actracer.h"
|
||||
#include "ksemaphore.h"
|
||||
|
||||
#include "task.h"
|
||||
#define TASK_MAX_PRIORITY 32
|
||||
|
||||
struct Thread* max_priority_runnable_task(void);
|
||||
struct Thread* round_robin_runnable_task(uint32_t priority);
|
||||
void recover_priority(void);
|
||||
struct ScheduleNode {
|
||||
TraceTag task_ref;
|
||||
struct double_list_node list_node;
|
||||
};
|
||||
|
||||
struct Scheduler {
|
||||
TraceTag tag;
|
||||
|
||||
struct double_list_node task_list_head[TASK_MAX_PRIORITY]; /* list of task control blocks that are allocated */
|
||||
struct double_list_node task_running_list_head;
|
||||
struct double_list_node task_blocked_list_head;
|
||||
struct double_list_node task_sleep_list_head;
|
||||
struct XiziSemaphorePool semaphore_pool;
|
||||
};
|
||||
@@ -67,6 +67,7 @@ typedef enum {
|
||||
SYS_STATE_SHOW_CPU_INFO,
|
||||
SYS_STATE_GET_CURRENT_TICK,
|
||||
SYS_STATE_GET_CURRENT_SECOND,
|
||||
SYS_STATE_SHOW_ACTREE,
|
||||
} sys_state_option;
|
||||
|
||||
typedef enum {
|
||||
|
||||
Reference in New Issue
Block a user