#include <Arduino_FreeRTOS.h>

#define RED    6
#define GREEN 7


int RedLEDProfiler;
int  GreenLEDProfiler;


TaskHandle_t red_Handle,Green_Handle;

int suspendMonitor;
int resumeMonitor;
bool suspend = false;

void setup()
{
  Serial.begin(9600);
  xTaskCreate(redLedTask,"Red LED Task",100,NULL,1,&red_Handle);
  xTaskCreate(GreenLedTask,"Green LED Task",100,NULL,1,&Green_Handle);
}

void redLedTask(void *pvParameters)
{
  pinMode(RED,OUTPUT);

  while(1)
  {
   digitalWrite(RED,digitalRead(RED)^1);
    RedLEDProfiler++;
    Serial.print("RED Run Time : ");
    Serial.println(RedLEDProfiler);
    suspendMonitor++;
    if(suspendMonitor>=30)
      {  
         suspendMonitor = 0;
         suspend = true;
         vTaskSuspend(NULL);  
     } 
    delay(2000);
  }
}


void GreenLedTask(void *pvParameters)
{
   pinMode(GREEN,OUTPUT);
  while(1)
  {

    digitalWrite(GREEN,digitalRead(GREEN)^1);
    GreenLEDProfiler++;
    Serial.print("GREEN Run Time : ");
    Serial.println(GreenLEDProfiler);
    Serial.println(" ");
    delay(200);
    if(suspend)
    {
      resumeMonitor++;
      if(resumeMonitor >=30)
      {
        vTaskResume(red_Handle);
        resumeMonitor = 0;
        suspend = false;
      }
    }
  }
}

void loop()
{}