1
0
Fork 0
forked from koniifer/ableos

scheduler work done

This commit is contained in:
Able 2022-01-25 19:02:22 -06:00
parent 21b5add99d
commit 6010397f4a

View file

@ -1,5 +1,14 @@
#![allow(clippy::empty_loop)] #![allow(clippy::empty_loop)]
use alloc::{format, vec::Vec};
use crate::{
boot_conf::BootConfig,
scheduler::{self, SCHEDULER},
};
// use crate::scheduler;
use { use {
crate::{ crate::{
arch::{init, sloop}, arch::{init, sloop},
@ -12,11 +21,9 @@ use {
relib::math::rand::RAND_HANDLE, relib::math::rand::RAND_HANDLE,
relib::network::socket::Socket, relib::network::socket::Socket,
relib::network::socket::{SimpleSock, SocketReturns}, relib::network::socket::{SimpleSock, SocketReturns},
scheduler::{test_fn, Thread, ThreadList},
vga_e::{self, num_to_vga16}, vga_e::{self, num_to_vga16},
}, },
alloc::{ alloc::{
format,
string::{String, ToString}, string::{String, ToString},
vec, vec,
}, },
@ -39,64 +46,76 @@ pub extern "C" fn stack_overflow() -> u8 {
lazy_static! { lazy_static! {
pub static ref KEY_BUFFER: spin::Mutex<String> = spin::Mutex::new("".to_string()); pub static ref KEY_BUFFER: spin::Mutex<String> = spin::Mutex::new("".to_string());
pub static ref THREAD_LIST: spin::Mutex<ThreadList> = spin::Mutex::new(vec![]);
pub static ref TICK: AtomicU64 = AtomicU64::new(0); pub static ref TICK: AtomicU64 = AtomicU64::new(0);
pub static ref BOOT_CONF: BootConfig = boot_conf::BootConfig::new();
} }
#[no_mangle] #[no_mangle]
pub fn kernel_main() -> ! { pub fn kernel_main() -> ! {
let boot_conf = boot_conf::BootConfig::new();
init::init(); init::init();
log::set_max_level(boot_conf.log_level()); log::set_max_level(BOOT_CONF.log_level());
// info!("Initialized"); // info!("Initialized");
graphics_pipe_startup(); graphics_pipe_startup();
/* if false {
let mut proc_1 = SimpleSock::new();
proc_1.register_protocol("ProcessSpawner".to_string());
{ let version = 0;
let mut proc_1 = SimpleSock::new(); use rkyv::ser::Serializer;
proc_1.register_protocol("ProcSpawner".to_string()); let mut serializer = AllocSerializer::<0>::default();
serializer.serialize_value(&version).unwrap();
let version = 0; let bytes = serializer.into_serializer().into_inner();
use rkyv::ser::Serializer; proc_1.write(bytes.into_vec());
let mut serializer = AllocSerializer::<0>::default(); unsafe {
serializer.serialize_value(&version).unwrap(); let the_bytes = proc_1.read(3).unwrap();
let archived = rkyv::archived_root::<Version>(&the_bytes);
let bytes = serializer.into_serializer().into_inner(); let deserialized: Version = archived.deserialize(&mut rkyv::Infallible).unwrap();
proc_1.write(bytes.into_vec()); trace!("{:?}", deserialized);
unsafe {
let the_bytes = proc_1.read(3).unwrap();
let archived = rkyv::archived_root::<Version>(&the_bytes);
let deserialized: Version = archived.deserialize(&mut rkyv::Infallible).unwrap();
// trace!("{:?}", deserialized);
}
} }
*/ }
let mut graphics = SCREEN_BUFFER.lock(); use crate::scheduler::Priority;
graphics.force_redraw(); let mut scheduler = SCHEDULER.lock();
graphics.clear();
screen_writer_test(); use Priority::*;
graphics.draw_filled_circle(100, 100, 50, 0x9900ff00); scheduler.new_process(High);
scheduler.new_process(High);
scheduler.new_process(Low);
scheduler.new_process(Low);
scheduler.new_process(Low);
scheduler.new_process(Low);
scheduler.new_process(Medium);
scheduler.new_process(Medium);
scheduler.new_process(High);
graphics.copy_to_buffer(); for x in &scheduler.list {
trace!("{:?}", x);
}
drop(scheduler);
if boot_conf.run_tests { use crate::wasm::WasmProgram;
let ret = WasmProgram::new_from_bytes(&[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]);
trace!("Binary Valid: {:?}", ret.validate_header());
// add a plus b
if BOOT_CONF.run_tests {
// quick and dirty testing framework // quick and dirty testing framework
screen_writer_test();
socket_test(); socket_test();
graphics_pipe_test(); graphics_pipe_test();
socket_startup_rng(); socket_startup_rng();
socket_test_rng(); socket_test_rng();
} }
if boot_conf.run_demos { if BOOT_CONF.run_demos {
graphics_api_demo(); graphics_api_demo();
} }
if boot_conf.run_shader_tests { if BOOT_CONF.run_shader_tests {
shader_tests(); shader_tests();
} }
@ -115,6 +134,10 @@ pub fn tick() {
RAND_HANDLE.lock().seed_entropy_timer(data); RAND_HANDLE.lock().seed_entropy_timer(data);
crate::kernel_state::KERNEL_STATE.lock().update_state(); crate::kernel_state::KERNEL_STATE.lock().update_state();
let mut scheduler = SCHEDULER.lock();
scheduler.bump_exec();
TICK.store(data, Relaxed) TICK.store(data, Relaxed)
} }
@ -122,14 +145,6 @@ pub fn key_entropy(key: u8) {
RAND_HANDLE.lock().seed_entropy_keyboard(key); RAND_HANDLE.lock().seed_entropy_keyboard(key);
} }
pub fn test_threads() {
let mut a_thread = Thread::new();
a_thread.new_task(test_fn);
a_thread.new_task(test_fn);
THREAD_LIST.lock().push(a_thread);
}
pub fn cpu_socket_startup() { pub fn cpu_socket_startup() {
let mut cpu_info_socket = SimpleSock::new(); let mut cpu_info_socket = SimpleSock::new();
cpu_info_socket.register_protocol("CPU_INFO".to_string()); cpu_info_socket.register_protocol("CPU_INFO".to_string());
@ -197,10 +212,13 @@ pub fn screen_writer_test() {
let mut sock_print_id = SimpleSock::new(); let mut sock_print_id = SimpleSock::new();
sock_print_id.register_protocol("Screen Printer".to_string()); sock_print_id.register_protocol("Screen Printer".to_string());
//
// sock_print_id.write(format!("a原 b画 cフ dァ eイ fル 集").into()); // sock_print_id.write(format!("a原 b画 cフ dァ eイ fル 集").into());
// sock_print_id.write(format!("λ³ Half Life 3 booting up ㎣").into()); // sock_print_id.write(format!("⋮").into());
sock_print_id.write(format!("Happy birthday 🎉").into());
sock_print_id.write(format!("λ³ Half Life 3 booting up ㎣").into());
// sock_print_id.write(format!("Happy birthday 🎉").into());
// sock_print_id.write(format!("I look forward to ur ai stuff :^>").into());
// sock_print_id.write(format!("1....2....3....4....5....6....7....8....9").into()); // sock_print_id.write(format!("1....2....3....4....5....6....7....8....9").into());
let mut prev = None; let mut prev = None;