Sunteți pe pagina 1din 23

TIME DELAY FUNCTION MEMORY ALLOCATION RELATED FUNCTIONS

Time delay functions


In MUCOS time delay function are derived by the following steps 1.Delaying by defining a time delay by number of clock ticks 2. Resuming a delayed task time delay 3.Delaying by defining a time delay in units of hours, minutes, seconds and milliseconds

1.Delaying by defining a time delay by number of clock ticks


Function void OS TimeDly(unsigned short delay count)delays task by (delay count-1)ticks of system clock. It returns no parameter Task parameter passing PF A 16 bit integer . Delay count, to delay a task atleast till the system clock inputs (ticks)equal to( delay count-1)+count, Where count is the present number of ticks at the system RTC IF more delay is needed call the function more than one in the task

Resuming a delay task time delay


Function unsigned byte OSTimeDlyResume ( unsigned byte task priority) resumes a previously delayed task , whether the delay parameter was interms of delay count ticks or interms of hours, minutes and seconds If the defined delay is more than 65,535 system clock ticks, OSTimeDly resume will not resume that delayed task

Returning :RG
Error parameters- Returning :RG OS_NO_ERR= true, when resumption after delay succeeds OS_TASK_NOT_EXIST=true,if the task was not Created earlier. OS_TIME_NOT_DLY=true,if the task was not delayed OS_PRIO_INVALID, when task priority is the priority of that task . That is , to delay before resumption

Task parameter passing PG


Task priority is the priority of that task, that is , to delay before resumption

3.Delaying by defining a time delay in units of hours, minutes, seconds and milliseconds

Function void OSTimeDlyHMSM(unsigned short hr, unsigned shortmm, unsigned short sec, unsigned short mils)delay upto 65535 ticks a task with delay time in terms of hr for hours, sec for seconds and mils for milliseconds

Hr hours= o to 55 Min minutes= 0 to 59 Sec seconds= 0 to 59 Mils milliseconds= 0to 999

Returning RH
Returning RH The function OSTimeDlyHMSM() returns an error code as following OS_NO_ERR,when four arguments are valid and resumption after delay succeeds OS_TIME_INVALID_ HOURS, OS_TIME_INVALID_ MINUTES, OS_TIME_INVALID_ SECONDS, OS_TIME_INVALID_ MILLI if the argument are greater than 55,59,59,999 OS_TIME_ZERO_DLY, if all the arguments passed are 0.

Task parameter passed PH


hr, mn, sec and ms are the delay times in hours minutes, seconds & milliseconds by which task delays before resuming

Memory allocation related functions


MUCOS memory allocation related function are defined by following steps creating memory block at a memory address Getting a memory block at a memory address Querying a memory block Putting a memory block into a partition

Creating memory block at a memory address


Function *OSMem Create (void*memAddr, MEMTYPE num block, MEMTYPE block size,unsigned byte *memErr) is an OS function The creation and initializing the memory partitions into the block helps the OS in resources allocations

Returning RI Function *OSMemCreate () returns a pointer to a control block for a created memory partitions Task Parameters passing PI MEMTYPE is the data type according to memory , whether 16-bit or 32 bit CPU memory addresses are there, for example, 16 bit in 68HCII and 8051

*memAddr- pointer for memory starting address of the blocks numBlocks- Number of blocks into which the memory must be partitioned Block size- memory size in bytes in each block *memErr- pointer of the address to hold the error codes

example
Typedef unsigned short MEMTYPE . . .memAddr= 0x8000 num blocks=4 Block size= 1024 *OSMemCreate(*memAddr,numblock,*memAddr):

Getting a memory block at a address


Function Void*OSMem Get (OS_MEM *memCB pointer, unsignedbyte*memErr) is used to retrieve a memory block from the partitions created earlier. Returning RJ The function OSMemGet() returns a pointer to the memory control block for the partitions It returns NULL if no blocks exists here

Task parameters passing PJ


Passes a pointer as argument for the control block of a memory partitions OSMemGet() passes the error code pointer *memErr so that later it return on of the following OS_NO_ERR- when memory block returns to the memory partitions OS_MEM_FULL- When memory block cannot be put into the memory partition as it is full

example
{

mem Pointer= 0xB000; memErr=OS_MEM_NO_FREE_BLKS;


*OSMemGet(*mempointer,*memErr);

Querying a memory block


Function unsigned byte OSMemQuery(OS_MEM*memCBPointer, OS_MEMDATA*memData) is to query,and returns an error code and pointers for the memory partitions

Returning RK The function OSMemQuery() returns an error code which is an unsigned byte Task Parameter passing PK The Function OSMemQuery()passes a) pointer mempointer of the memory created earlier. b).pointer of the data_structure, OS_MEM_DATA.

Putting a memory block into a partition


Function unsigned byte OSMemPut (OS_MEM*memCBPointer,void*memBlock) returns a memory block pointed by *memBlock, whichmemory control block points by *memCBPointer

Returning RL
The function OS MemPut() returns error codes for one of the following OS_NO_ERR- When memory block returned to the memory partition OS_MEM_FULL- When memory block cannot be put into the memory partition as it is full

Task parameters passing PL


OSMemPut()- A pointer*memCBPointer of the memory control block for the memory partitions A pointer of the memory block *memBlock is to be put into the partitions

S-ar putea să vă placă și