Example of
Channel Polymorphism MemoryChannel to Linkable or BaseChannel
ALL Channel Types can be cast as a "BaseChannel"
First element of a core or sub channel is always a Channel
struct.
First element of Channel Struct is a Stuct Linkable.
struct
Channel
//@struct Channel
{
struct Linkable
node;
//-- struct Linkable tLink =(struct Linkable *)Channel. Now
its Linkable.
struct Channel *parent_channel; //
uint64_t
io_flagbits;
//read. 0xffff0000 0x0000ffff write
uint64_t ch_index;
char name [256];
char code_base[256];
char url [256];
char *read_buffer; //
char *write_buffer; //
volatile char
*io_ctl[4]; // read(0 system
1 user).write(2 system,3 user)
volatile char *read_list[16][2];
volatile char *write_list[16][2];
struct StateMachine *state_machine;
struct GraphicsContext graphics;
struct Runtime
*runtime;
struct Channel
*sub_channel[16];
};
//
#define HEAP_MEMORY 0
// malloc();
#define STACK_MEMORY 1 //
stalloc();
#define IPC_MEMORY
2 // shalloc();
#define GPU_MEMORY
3 // galloc();
#define CLOUD_MEMORY 4 //
clalloc();
#define REGISTRY_MEMORY 5 // ralloc();
#define PAGE_MEMORY 6
// palloc();
#define MEMORY_TYPE_NUMBER 6
struct MemoryChannel //@struct MemoryChannel
{
struct Channel
base;
//FIRT Position We are a Channel first Channel location is struct Linkable
struct HyperLinkedList memory_list[MEMORY_TYPE_NUMBER];
uint64_t
mc_size
[MEMORY_TYPE_NUMBER];
uint64_t
mc_allocated
[MEMORY_TYPE_NUMBER];
uint64_t
mc_remaining
[MEMORY_TYPE_NUMBER];
};
struct Channel *tChannel = (struct Channel *)&MemoryChannel; // Now we are a Base
Channel.
struct Linkable *tLink = (struct
Linkable *)&MemoryChannel;