Pages

Thursday, January 14, 2016

SQL Server 2012 Capacity Constraints

When designing SQL Server 2012 deployment , one should keep in mind the capacity constraints of SQL Server Database Engine.

1. Maximum size of database : 524,272 TB
2. Maximum size of single file : 16 TB
3. Maximum number of databases that can be hosted : 32,767
4. Maximum number of columns involved in a primary key : 16
5. Maximum number of foreign key references : 253
6. Maximum number of user connections : 32,767

Thursday, December 24, 2015

Library Function Vs System Calls

Standard functions can be classified into two major categories:

1. Library function calls
2. System function calls

Library Functions
System Calls
They are part of standard C library and executes in user space. Eg: strcmp(), malloc()
These functions change the execution mode of the program from user mode to kernel mode. Eg: open(), read()
Library functions may or may not make system calls.
They are called by library functions and executed by kernel.
Library functions are portable i.e. an application using library functions will run on every system.
An application relying on system call may not run on every system as system call interface may vary from system to system.
Library functions can be debugged using a debugger.
System calls cannot be debugged as they are executed by kernel.


How does system calls switch modes ?

Traditionally, the mechanism of raising an interrupt of ‘int $0x80′ to kernel was used. After trapping the interrupt, kernel processes it and changes the execution mode from user to kernel mode. Today, the systenter/sysexit instructions are used for switching the execution mode.



Monday, November 9, 2015

insmod: ERROR: could not insert module hello.ko: Invalid parameters

I encountered this problem when I tried passing variables from command line using module_param for the first time.

This problem has a simple solution. The solution is that the assignment operator used to assign the value should not have any spaces before or after the operator.

I am using the following code :

#include <linux/module.h>   /* Needed by all modules */

#include <linux/kernel.h>   /* Needed for KERN_INFO */
#include <linux/moduleparam.h>

static int myvar = 1;
module_param(myvar, int , 0);
MODULE_PARM_DESC(myvar, "An integer");

static int __init init_hello(void)
{
        printk(KERN_INFO "Hello world 1.\n");
        printk(KERN_INFO "myvar is an integer: %d \n", myvar);
        return 0;
}

static void __exit cleanup_hello(void)
{
        printk(KERN_INFO "Goodbye world 1.\n");
}
module_init(init_hello);
module_exit(cleanup_hello);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Sandesh Shrestha");

After I compile using make, I used the following command to insert the module:

ubuntu@sandesh:~/cpractice[00:44]$  sudo insmod hello.ko myvar=10

Please note that there are no spaces before and after the assignment operator.

Sunday, October 4, 2015

Process priority in Linux

Linux uses the priority based scheduling algorithm. It ranks the processes based on their worth and need for processor time. The Linux kernel implements two separate priority ranges.

1. Nice Values:
             It is a number between -20 and +19 with a default value of 0. Larger nice values correspond to a lower nice values i.e. it is nice to the other processes in the system. Thus, processes with lower nice values receive a greater proportion of the system processor as compared to processes with a higher nice value. In Mac OS X nice values control over the absolute time-slice. In Linux, it is the control over the proportion of the time-slice.

ps -el commmand gives the processes and their corresponding nice values.

The getpriority and setpriority functions gets and sets the nice values. (http://linux.die.net/man/2/setpriority)

Nice values can be set from the linux command line using the nice command. To set lower priority to a process to avoid slow down of other processes, we can use the following command.

$ nice -n 19 tar cvzf archive.tgz largefile

2. Real-time priority:
         These priority values range from 0 to 99 inclusive with default value being 0. Unlike nice values, higher real-time priority values mean higher priority. All real time processes are at a higher real-time priority value than other processes.

The command below gives the list of processes and their real-time priority values under the column marked RTPRIO.

ps -eo state,uid,pid,ppid,rtprio,time,comm

A value of "-" means the process is not real time.






Friday, October 2, 2015

Types of Kernel

Kernels can be classified into the following categories:

1. Monolithic
                In this type of architecture, all the basic system services like process and memory management, interrupt handling etc were packaged into a single module in kernel space.

Earlier version of this architecture had the following drawbacks:

      a. The size of kernel was huge.
      b. Bug fixing or addition of new features resulted in                  recompilation of whole kernel.

However, the modern architecture which Linux uses is much better and includes feature to dynamically load the modules thus facilitating easy extension of OS's capabilities. 

Linux follows the monolithic modular approach.

2. Microkernels:
           In this type of architecture, only the bare minimum is implemented in kernel space which includes managing memory protection, process scheduling and inter process communication (IPC) thus decreasing the kernel size and increasing security and stability of OS. Other basic services like device driver management,protocol stack, file systems, graphics, etc are implemented in user space and are run as servers. These servers are different from other user space programs as kernel grants them permissions to interact with physical memory which is usually off limits to most programs. Thus these serves can interact directly with the hardware. These services are started at system startup.

QNX follows the microkernel approach.

3. Hybrid Kernel:
            Hybrid kernel is the most successful kernel implementation and is used in operating systems like Windows NT and above and Mac OS X. This type of kernel are extension of microkernel with some properties of monolithic kernel. Hybrid kernels are microkernel that has some non-essential code in kernel space in order for the code to run faster than it would have been in user space. Unlike monolithic kernel, they are unable to load modules at run time.

The hybrid kernel approach combines the speed and simpler design of a monolithic kernel with the modularity and execution safety of a microkernel.

Wednesday, September 23, 2015

Named Pipe(FIFO) and Unnamed Pipe(Pipe) : Differences


Pipes are synchronized way of passing information between processes.

Differences:


                         Unnamed Pipe(PIPE)
                                    Named Pipe(FIFO)
 They are unidirectional.
 They can be bidirectional.
They can only be used by related processes (parent/child or child/child having the same parent.)
They can be used by any process (unrelated processes.)
They are opened at the time of creation only.
They are not open at the time of creation.
They exist as long as the file descriptors are open.
They exist as directory entries
They are created by using the function pipe().
They are created by using the function mkfifo().
Eg: int pipe(int fd[2])
fd[0] – descriptor used for reading
fd[1] – descriptor used for writing
Eg: int mkfifo(char *path, mode_t mode)

Sunday, September 13, 2015

Character devices and Block devices


There are two main types of devices under Linux systems, block devices and character devices.

Character Devices
                                  Block Devices
The devices that conveys data character by character between the device and the user program.
The devices that read/write data in fixed size blocks.
Eg: Mouse, Keyboard
Eg: USB, Hard Disk
No buffering is performed
Block devices are accessed through a buffer
The first character is ‘c’ in the output of ls -l
cd to /dev and run the command ls -l
The first character is ‘b’ in the output of ls -l
cd to /dev and run the command ls -l