none
Avrt.h library (MMCS) and Windows Server 2012 R2

    Question

  • The piece of code below runs without any problem in Windows Server 2012 R2 (GUI version and minimal interface version) but not in Core version:

    // avrtExample.cpp. VS2015 options: Release x64
    
    #include "stdafx.h"
    #include <thread.h>
    #include <windows.h>
    #include <synchapi.h>
    #include <tchar.h>
    #include <iostream.h>
    #include <fstream.h>
    #include <string.h>
    #include "atlstr.h"
    #include "immintrin.h"
    #include "Avrt.h"
    
    using namespace std;
    
    int main()
    {
    	#pragma comment(lib, "Avrt.lib")
    
    	std::cout << "*************************************" << endl;
    	Sleep(100);
    
    	DWORD err;
    	DWORD taskIndex = 0;
    	HANDLE task = AvSetMmThreadCharacteristics(TEXT("Pro Audio"), &taskIndex);
    	if (!task) {
    		err = GetLastError();
    		std::cout << "AvSetMmThreadCharacteristics failed (error code=" << err << ")." << endl;
    		exit(1);
    	}
    	bool mmcss_is_ok =
    		(task && AvSetMmThreadPriority(task, AVRT_PRIORITY_CRITICAL));
    	if (!mmcss_is_ok) {
    		err = GetLastError();
    		std::cout << "AvSetMmThreadPriority failed (error code=" << err << ")." << endl;
    		exit(1);
    	}
    	std::cout << "SUCCESS" << endl;
    	return 0;
    }

    However, when I switch off the GUI, and go to Window Server Core mode, it does not work anymore.  I compiled with the static Avrt.lib. It seems that the execution of the lines having AVSet* calls kills also that initial dummy print.

    P.S. I prepared the above small self-contained C++ example (with extra includes as in my code) for a Windows Console project (so stdafx.h is the default one). It can be run under Windows Server 2012 R2: GUI version (it prints) vs Core version (it does not print). In the latter case, the executable does not produce any output...

    I tried "sc start MMCSS" and similar for the Multimedia Class Scheduler service, but that service does not exist. What am I missing? Which commands should I launch to selectively install MMCSS in Core mode, without installing the rest of the Mininal Interface?

    Thanks
    -Roberto

    P.S. I already posted this question in two forums and I was headed here.

    https://social.msdn.microsoft.com/

    https://social.technet.microsoft.com/



    • Edited by RobHicSunt Thursday, February 25, 2016 4:53 PM
    Thursday, February 25, 2016 4:51 PM

All replies

  • Hi RobHicSunt,

    This forum is discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    Please try run your project with the same version of Visual Studio on another computer which is not Windows Server. If it works fine in another computer, this problem may be caused by Windows Server. If it also has this issue, please try with below steps to repair your Visual Studio to check whether it can fix this issue.

    1. Please install the latest update for your Visual Studio. The latest Update for Visual Studio 2015 is Update 1.
    2. Please repair your Visual Studio to check whether it can fix this issue.

    About how to install MMCSS in Windows Server Code mode, I think the Windows Server Forum is a appropriate forum.

    In addition, could you please provide a sample project to help us reproduce your problem, which can let us debug your code in Server Core mode.

    Best Regards,
    Weiwei


    Friday, February 26, 2016 8:43 AM
    Moderator
  • Thanks Weiwei, I tried what you suggest before posting. Here is the sample VS project for the above example reproducing my issue.

    avrexample

    Cheers

    -Roberto


    Sunday, February 28, 2016 1:44 PM
  • Hi RobHicSunt,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Thanks for your understanding!


    Best Regards,
    Weiwei

    Tuesday, March 01, 2016 6:51 AM
    Moderator
  • Dear Weiwei,

    I appreciate a lot your help :)

    Thanks

    -Roberto

    Tuesday, March 01, 2016 8:56 AM
  • This problem is related to C++ and Windows Server. I think you should not post this problem here.

    Please try debug your code on Windows Server Core to check whether there has some problem with your code and Windows Server Core.

    Thursday, March 10, 2016 6:44 AM