hmmm, isnt MP3007 talking about me?
by default, my system is a combination of polled-loop and interrupt-driven. when not interrupted, my cpu will be polling for the queued tasks. hence, i will go and poke everyone online on my msn. its not my fault, its just that my scheduling is set to polling when idle. the scheduling algorithm cannot be change unless the program has the apporiate permission, aka, jenny ma (haha. but she dunnoe how to use int sched_setscheduler(pid, policy, *param); ).
the scheduling is set to round the robin the robin, meaning all process will get cpu time, starting from the highest priority, until all the processes have finish excuting. with this scheduling, new processes can be added! so i aways have new things to do making me having endless of processes to excuted! this explains why my hobbies are always changing; once a certain hobby has finish excuting, it has to wait for a very long time until the cpu comes back to that hobby.
all processes created will be given a priority using int setprio(pid, prio); and they can be interrupted by signals, depending on the priority of the current process and the interrupt signals. for critical processes, such as chatting with eyecandy, playing killer sudoku or watching tv, a int sigblock(mask); will be done to prevent interrupts. the interrupt codes will only be run after the critical process, when a int sigsetmask(mask); is excuted.
when situation calls, more processes may be created from my main program using int spwanl(mode, *path, *arg[x], NULL);. the behaviour of these processes is set by the mode.
P_WAIT: the main process waits for the new process to finish before continuing. example, when im just surfing the net, or studying (anything except for the critical processes), a SIGUSR1 is set for me to go to bathe. i will create a new process to bathe, while pausing the original process. the original process will continue running after i finish bathing.
P_OVERLAY: the new process will replace the original process and will never go back again. example, when im suppose to go for a jog (im on diet remember?), i create a watchtv.exe with P_OVERLAY mode. my cpu will run the watchtv process and the orignal jogging process will be terminated until the next time its created.
P_NOWAIT: both original and new process will run together. this mode is being used everyday during my dinner. whenever i have my dinner, a process to watch tv will be created. and both eating dinner and watching tv will occur together.
the only way to terminate my critical processes is using SIGKILL. however, using SIGKILL command might reap undesired results during to improper termination of process. this is especially so when im running critical code int sleep(int time); although SIGALARM has been set using int timer_create(clock_id, *evp, timerid); and int timer_settime(timerid, flags, *value, *oldvalue);, the structure of c-program for this part of yanxin seems to be in an endless while(1) loop. meaning, the settime, and sleep, and reset time, and sleep, and reset time, and sleep is always looping until a higher priority interrupt occurs. in layman's term, im always snoozing my alarm clock, until my phone rings, with yh on the line telling me he is already downstairs.
for communication and synchronization, im using int MsgSend(id, *smsg, sbytes, *rmsg, rbytes);, int MsgReceive(chid, *msg, nbytes, *info); and int MsgReply(revid, status, *msg, nbytes); most of the time. before achieving communication with me, a server name must be created using name_attached(); and the client must locate the channel using name_open();. meaning, if i dont want to talk, i will not start any channel, so all the messages will not be able to send to me. Even if the communication is already established, i can end it with a name_detech();, and any messages after that will be returned with an error (-1).
when lots of messages are passed to me, i will use int pipe(filedes[2]);. however, this pipe have limited size. so dont tell me too much things and expect me to remember. i have small memory. to ensure that my buffer dont overload, queuing model (M/M/1) should be followed. this basically means, write() to me shouldnt occur more frequently read() from me. in yanxish, i talk more than i listen. (haha. i always try to listen. but i need to talk to empty my buffer. not my fault again k)
cpu time consuming processes are avoided at all cost. for example, chatting on the phone. however, if the process is created, a delay() is added to free the cpu time for other processes. hence, my phone conversations are always filled with silence and an occasional "uh huh". the rest of the cpu time are given to other processes.
so, MP3007 is within me all the time! meaning any excution error will terminate the process with a "Memory fault (core dumped)". haha. now i feel as dumb as a c-program.
Memory fault (core dumped)
No comments:
Post a Comment