Creating a system call in the kernel to be used by a user-space application isn’t that exotic but requires three basic steps.
The first step is to create the function, to update the header files and to update the system call table.
We will create the function with the asmlinkage modifier, which tells the compiler to pass all function argument on the stack.
A simple system call function could be
asmlinkage int calculate (int a, int b) { printk (“total\n”); return a+b; }
Now we need to update the header files for the new function in the system call table.
Open the unistd.h file in linux/include/asm/ and add
#define __NR_calculate 110
** remember 110 here is the next in numerical order – would be different everytime
After making space for the system call in the header file, we need to now update the system call table “syscall_tables.S” (linux/arch/i386||x86_64/kernel/syscall_table.S
.long sys_getjiffies
recompile the kernel, make the image and reboot // and use your system call
Q: How do I delete files that older than a certain amount of days and which are empty
A: find . -empty -type f -mmtime +X | xargs rm or for those fancing exec, use find . -empty -type f -mmtime +X -exec rm {}
** X must be replaced with the number of days
cheers,
1. if you were to use between print or echo… use echo (Echo is known to be faster than print)
2. when doing string searches or action, do not simply/quickly jump on regex, but first have a look at php api’s string functions such as strpbrk, stripos etc..
3. Display smart error messages… A lot of young developers like to display a custom error or show systems errors whenever something break. Although it is good practice to alert the user of any error, keep in mind printing Error cost a lot in resources. Go for general error display then specifics.
4. Close your database connections when you are done processing mysql datas
5. Use variables instead of global variables
6. Always initialize your variables… It seems too common for coders to just declare a variable without initializing it and process it later with increments etc… Remember you are loosing on speed with none initialized variables
7. Whenever you echo a string on the string.. use ‘ ‘ instead of ” “… why? because PHP will look inside the ” ” declaration for any variables “$”… the process is therefore slower
8. Use mem-cached with apache as to cache memory objects. This will highly speed up the runtime execution of your web application
9. Use mod_gzip to compress data delivery
10. Implement data structure as array and not as class
and yes…
use less OOP as possible, being a JAVA and .NET programmer, I can guarantee that OOP in PHP is just a big overhead.
till later,