CPU timeslicing calculation


Out of a 1000 time slices the OS itself uses 100 of these (assume that these are spread at regular intervals over each second) it can make 900 such time slices available for virtual machines each second. The computer needs to run 10 programs that each require a time slice at least 20 times per second and one program (the user interface) that requires a time slice at least once every 10 milliseconds.

Does this mean that:

OS = 100 time slices

10 Programs = 200 time slices

UI = 100 time slices

Resulting in 600 time slices left for other programs to run?

How to speed up the calculation of a multi-dimension matrix involving symbolic integral?

The following program succeeds in getting matrix CC, but it takes time badly, especially in the case varNumber becomes larger just as the following varNumber = 35. Who can speed up the process of calculation? Thanks!

ClearAll["Global`*"]; varNumber = 35; end = Infinity; s1 = 112*^9; s2 = 25*^9; s3 = 15.1; s4 = 5.5*10^-9;  a[m_] := Exp[-x/2]*LaguerreL[m, x]; b[m_, i_, j_, l_] := Integrate[a[m]*x^i*D[a[l], {x, j}], {x, 0, end}];  d[m_, i_, j_, l_] :=   Integrate[   a[m]*x^i*D[     a[l], {x, j}]*(DiracDelta[x] -       DiracDelta[x - end]), {x, -Infinity, Infinity}];  c[1, 1][m_, l_] := s2*d[m, 0, 1, l] + s2*b[m, 0, 2, l]; c[1, 2][m_, l_] := 0; c[1, 3][m_, l_] := 0; c[2, 1][m_, l_] := 0; c[2, 2][m_, l_] := s1*d[m, 0, 1, l] + s1*b[m, 0, 2, l]; c[2, 3][m_, l_] := s3*d[m, 0, 1, l] + s3*b[m, 0, 2, l]; c[3, 1][m_, l_] := 0; c[3, 2][m_, l_] := s3*d[m, 0, 1, l] + s3*b[m, 0, 2, l]; c[3, 3][m_, l_] := -s4*d[m, 0, 1, l] - s4*b[m, 0, 2, l];  CC = ArrayFlatten@     Table[c[m, n][i, j], {m, 3}, {n, 3}, {i, 0, varNumber - 1}, {j, 0,        varNumber - 1}]; // AbsoluteTiming {2283.69, Null} 

Rating Scale Calculation excluding the N/A Answer – Cognito Forms

I have created a feedback form in Cognito forms to collect feedback for suppliers. I have a 1-5 rating scale with 14 Questions and a calculation field to calculate the percentage.

I have done the formula and managed to calculate all ratings. I have added the option to N/A to the rating. So I would like to exclude the question answered by N/A from the total number of questions. so the Formula should be if one of the questions is answered by N/A then it should be divided by 13 Questions and not 14.

Current Formula: Total Score / 14 / 5 ( Highest Rating )

Please advise

RAID 5/6 rebuild time calculation

I plan to build some storage schema but I have to anticipate downtime, maintenance and rebuild Time.

Some guys said to me that a 10 disk RAID6 of 10To (SATA) rebuild will last for about a week ! an some company policy ask for stopping activity on Array when rebuilding.

If I use RAID 5 or 6 or 5+1 or 6+1 is there an approximate formula that can give me hint on rebuild time depending on disk size and type (SAS/SATA/SSD). something like rpm x size(Mb) x type-factor x nb-of-disk …

I would like to be able to anticipate all rebuild time scenario depending on Size/type of RAID/type of Disk.

I know it may depend on hardware quality, but let says I am out of dedicated hardware like 3PAR / STOREWIZE / NETAPP or likes. I am using conventional servers with traditional SAS or SATA drives with software RAID.

Vector calculation in Rust

Hi I am trying to get into Rust by implementing a small library for vector calculations.

I am mainly asking to point out whether I chose a valid approach. I also am interested in comments on the overall details I might have missed or got the wrong way.

So for my Vec3 implementation I basically declared a custom type which is an array of length 3. Afterwards I am simply implementing Traits for this type. For now I only implemented it for f32.

pub type Vec3<T = f32> = [T; 3];  pub trait Vector3<T> {     /// Creates a new Vec3 with its values initialized to `[0.0, 0.0, 0.0]`.     fn new() -> Self;      /// Creates a new `Vec3` based on the given `x`, `y` and `z` values.     fn from_values(x: f32, y: f32, z: f32) -> Vec3<T>;      /// Calculates the scalar dot product of two `Vec3`'s.     fn dot(a: Vec3<T>, b: Vec3<T>) -> f32;      /// Performs multiplication between two `Vec3`.     fn multiply(self, a: Vec3) -> Vec3;      /// Calculates the sum of two `Vec3` components.Vec3     fn add(self, a: Vec3) -> Vec3;      /// Scales a `Vec3` by a scalar value.     fn scale(self, x: f32) -> Vec3; }  impl Vector3<f32> for Vec3<f32> {     /// Creates a new Vec3 with its values initialized to `[0.0, 0.0, 0.0]`.     ///     /// ```     /// use glMatrix_rs::vec3::*;     ///     /// let result = Vec3::new();     /// assert_eq!([0.0, 0.0, 0.0], result);     /// ```     fn new() -> Vec3<f32> {         [0.0, 0.0, 0.0]     }      /// Creates a new `Vec3` based on the given `x`, `y` and `z` values.     ///     /// ### Arguments     ///     /// * `x` - The first vector component.     /// * `y` - The second vector component.     /// * `z` - The third vector component.     ///     /// ```     /// use glMatrix_rs::vec3::*;     ///     /// let result = Vec3::from_values(0.0, 1.0, 2.0);     /// assert_eq!([0.0, 1.0, 2.0], result);     /// ```     fn from_values(x: f32, y: f32, z: f32) -> Vec3 {         [x, y, z]     }      /// Calculates the scalar dot product of two `Vec3`'s.     ///     /// ### Arguments     ///     /// * `a` - The first vector for `dot` calculation.     /// * `b` - The second  vector for `dot` calculation.     ///     /// ```     /// use glMatrix_rs::vec3::*;     /// let a = Vec3::from_values(2.0, 2.0, 2.0);     /// let b = Vec3::from_values(2.0, 2.0, 2.0);     /// assert_eq!(12.0, Vec3::dot(a, b));     /// ```     fn dot(a: Vec3, b: Vec3) -> f32 {         a[0] * b[0] + a[1] * b[1] + a[2] * b[2]     }      /// Performs multiplication between two `Vec3`.     ///     /// ### Arguments     ///      /// * `a` - Vector by which `self` will be multiplied.     ///     /// ```     /// use glMatrix_rs::vec3::*;     /// let mut out = Vec3::new();     /// let a = Vec3::from_values(1.0, 2.0, 3.0);     /// let b = Vec3::from_values(2.0, 2.0, 2.0);     /// assert_eq!([2.0, 4.0, 6.0], a.multiply(b));     /// ```     fn multiply(self, a: Vec3) -> Vec3 {         [self[0] * a[0], self[1] * a[1], self[2] * a[2]]     }      /// Calculates the sum of two `Vec3` components.Vec3     ///     /// ### Arguments     ///      /// * `a` - Vector which will be added to `self`.     ///     /// ```     /// use glMatrix_rs::vec3::*;     /// let x = Vec3::from_values(1.0, 2.0, 3.0);     /// let a = Vec3::from_values(3.0, 2.0, 1.0);     /// assert_eq!([4.0, 4.0, 4.0], x.add(a));     /// ```     fn add(self, a: Vec3) -> Vec3 {         [self[0] + a[0], self[1] + a[1], self[2] + a[2]]     }      /// Scales a `Vec3` by a scalar value.     ///     /// ### Arguments     ///      /// * `x` - Scalar value by which the vector will be scaled.      ///     /// ```     /// use glMatrix_rs::vec3::*;     /// let a = Vec3::from_values(1.0, 2.0, 3.0);     /// assert_eq!([2.0, 4.0, 6.0], a.scale(2.0));     /// ```     fn scale(self, x: f32) -> Vec3 {         [self[0] * x, self[1] * x, self[2] * x]     } } 

You can clone, build and test it any time from my GitHub repository.

How can i write the output of calculation on csv file like below format?

I reached below list after calculation of the hash password from the csv file:

['danial', 5104, 'elham', 9770] 

and i am going to write every name and password on csv file (update it) in below order:

danial,5104 elham,9770 

I have used below code, but the output is false.

data=[] for item in list3:     #data=[]     l3=[]     l3.append(item)     #print(l3)     data.append(str(item)) print(data)  with open('code.csv', 'w', newline='') as output_file_name:         writer = csv.writer(output_file_name)         writer.writerows(data)         output_file_name.close()  

Split calculation string into parts

Our professor has given us the following task (its part of a bigger document full of tasks):

Write a function in C that handles strings like “233+343” and parse them into the variables “iNum1”, “cOp” and “iNum2”. (I tried to translate it into english).

We mostly program in Java and my C knowledge consists of mostly provisional half knowledge.

But is my program beautiful enough to show it to a professor?

#include <stdio.h> #include <string.h>  #define ASCII_POS_OF_0 0x30 #define ASCII_POS_OF_9 0x39  void parse_calc_string(char string[]) {      // get first number     int iNum1 = 0;     int index = 0;     char current_char = string[index];     while (current_char >= ASCII_POS_OF_0 && current_char <= ASCII_POS_OF_9)     {         iNum1 *= 10;         iNum1 += (int)current_char - ASCII_POS_OF_0;         current_char = string[++index];     }      // get operation symbol     char cOp = current_char;     current_char = string[++index];      // get second number     int iNum2 = 0;     while (current_char >= ASCII_POS_OF_0 && current_char <= ASCII_POS_OF_9)     {         iNum2 *= 10;         iNum2 += (int)current_char - ASCII_POS_OF_0;         current_char = string[++index];     }      printf("iNum1: %i\n", iNum1);     printf("cOp  : %c\n", cOp);     printf("iNum2: %i\n", iNum2);     printf("\n"); }  int main() {     parse_calc_string("219+43");     parse_calc_string("195-143");     parse_calc_string("15*13");     parse_calc_string("212/14"); }